Cv2 module not found in tensorflow - opencv

I Installed opencv and cv2 in anaconda and created a tensorflow environment for imageprocessing.
tensorflow is present in
c:/Users/mayank singh/local/conda/conda/envs/tfdeeplearning/lib/site-packages
And cv2 is prensent in
c:/Programdata/Anaconda3/lib/site-packages
cv2 is working independently in jupyter notebook but shows error "module not found" after activating tensorflow

Related

opencv import error in jupyternotebook in ubuntu 22.04

enter image description here
I AM USING JUPYTER NOTEBOK IN UBUNTU 22.04.
I AM UNABLE TO IMPORT CV PACKAGE EVEN THOUGHI HAVE INSTALLED THE PACKAGE TO THE EVIRONMET.
I HAVE TRIED MANY THINGS ON WEB BUT IT IS ALWAYS SHOWING MODULE NOT FOUND ERROR.
IF ANY ONE HAVE SOLUTION FOR THIS PLEASE HELP ME.
I HAD TRIED INSTALLING FROM NOTEBOOK , IT SHOWS REQUIREMENTS ALREADY SATISFIED.

Unable to install Scipy latest version 1.9.3 on python3.8-alpine image

Trying to install Scipy latest version (1.9.3) on python3.8-alpine image
tiangolo/uwsgi-nginx-flask:python3.8-alpine
is not successful.
Scipy tries to install numpy 1.8.5 and it fails with following error.
ImportError: cannot import name 'Log' from 'distutils.log' (/tmp/pip-build-env-28q9f6x4/overlay/lib/python3.8/site-packages/setuptools/_distutils/log.py)
I can goahead and install lower version of scipy. But I am having issue with Sklearn
While trying to install sklearn, it tries to install latest scipy and it fails.
Is there a way i can enforce scipy version to be installed for sklearn
I had the same problem with alpine and python.
This article shows that alpine images should not be used with python as it:
Make your builds much slower.
Make your images bigger.
On occassion, introduce obscure runtime bugs.
I think that your problem comes from the fact that alpine image does not handle wheels files properly.
I would recommend you to switch from python:3.8-alpine to python:3.8-slim.
The problem comes from setuptools. Pin to a version less than 65. Scipy should build on Alpine from source without issue. One of the scipy continuous integration tests checks this. https://github.com/scipy/scipy/blob/main/ci/cirrus_general_ci.yml#L40.

Getting error in Jupyter Notebook when importing opencv after installation: libGL.so.1: cannot open shared object file: No such file or directory

I have installed python3 in my ubuntu 20.04LTS operating system. I have also installed the Jupyter notebook directly from the snap store. Now I am trying to install OpenCV from jupyter notebook using: pip install OpenCV-python.
I have also tried: !pip install OpenCV-python
In both the case it says requirement already satisfied. Below is the screenshot:
Whenever I am trying: import cv2.
It gives error:libGL.so.1: cannot open shared object file: No such file or directory.
Though I have installed OpenCV through the terminal in python3 and it successfully gets imported in python3 terminal. But not able to import in Jupyter notebook.
Please suggest, how can I resolve this issue and import OpenCV to Jupyter Notebook.
Any link where I can learn and understand how these libraries interact with the operating system when installed through python and Jupyter notebooks will be helpful.
Thanking you!
This is happening due to using pre-built CPUs. Install package as headless one.
I had similar issue that got resolved by using below command
pip install opencv-python--headless
reference https://pypi.org/project/opencv-python-headless/

importing python opencv library into sikuliX

I am trying to import the opencv library into sikuliX which uses Jython interpreter.
I have added the path where cv2 module is installed to sys.path.append to tell Jython to look for cv2 folder in the path supplied.
import sys
sys.path.append("/Users/ongyichong/anaconda3/lib/python3.7/site-
packages/")
import cv2
I installed opencv using pip install opencv-contrib-lib and the path where cv2 is installed in the path "/Users/ongyichong/anaconda3/lib/python3.7/site-packages/".
This is what my cv2 folder looks like.
The error arises because my init.py file contains a ".cv2 import *". I am not sure how i should go about solving this problem. Is there another way i can import python modules into SikuliX's Jython interpreter ?
Python (C-Python) modules can only be used in SikuliX (Jython interpreter) when they are completely written in Python language and do not contain any C-based stuff or even reference native libraries.
BTW: especially since SikuliX 1.1.4 the complete OpenCV 3 API is available at the Java level, which is also accessible from the Jython scripting level.

ImportError: No module named 'cv2' on Watson Studio

The command
import cv2
on Watson Studio results in the error
ImportError Traceback (most recent call last)<ipython-input-1-72fbbcfe2587> in <module>()----> 1 import cv2
ImportError: No module named 'cv2'
I'm not sure if I need to install opencv upfront and how to do this in a cloud environment like Watson Studio?
cv2 is part of opencv-python package.
Please install the pypi hosted libararies using !pip magic in jupyter notebook.
!pip install opencv-python
Then run the import cv2.
See this shared notebook
https://dataplatform.ibm.com/analytics/notebooks/v2/a0e50c53-ea28-4b78-800f-35cae2211389/view?access_token=b129fa46626e1bf317de18c9241af375d9a9ac8e11561e3735569050fe0b8839
Also see this documentation for installing third party libraries.
https://datascience.ibm.com/docs/content/analyze-data/importing-libraries.html

Resources