import opencv in python - python

I want to install opencv on Windows 7 64 bit and I'm using Python 3.5.1 32-bit.
I downloaded the .whl file for opencv as said in the answer in this question: Install opencv for Python 3.3 given by #user3731622. But when I try to do:
import cv2
I get the following error:
ImportError: numpy.core.multiarray failed to import
What am I doing wrong ?
Thanks

Are you sure it's bumpy in the error you get? multiarray is a part of numpy.
In this post: ImportError: numpy.core.multiarray failed to import
the solution is to install numpy. Do you have that installed?

Related

Matplotlib import error: "ImportError: DLL load failed while importing _path: The specific module could not be found"

I installed Python3.10 (64x)(download installer from the official website) on the clear Windows 10 (x64).
Using pip install <packetname> I installed packages: numpy, scipy and matplotlib.
enter image description here
Numpy and scipy work properly, but matplotlib import falls with ImportError: DLL load failed while importing _path: The specific module could not be found
enter image description here
It falls in the transforms.py on the command:
from matplotlib._path import ( affine_transform, count_bboxes_overlapping_bbox, update_path_extents)
I've tried reinstall matplotlib and install older versions - no result. Reviewing the forums with similar questions also wasn't successful.
Please, help me to get by this issue.

Tensorflow import error when loading PIL (pillow)

I'm having an issue with my tensorflow on windows 10 (python 3.7, tf 2.1.0, keras 2.3.1, pillow 7.1.1). I had some code I wrote on an osx machine and was porting over to windows. I am using conda envs and have all the necessary packages installed (tensorflow, keras, pillow, opencv, etc) but I am getting the following error
Traceback (most recent call last):
...
"...\venv\lib\site-packages\keras_preprocessing\image\utils.py", line 108, in load_img
raise ImportError('Could not import PIL.Image. '
ImportError: Could not import PIL.Image. The use of `load_img` requires PIL.
I have tried reinstalling pillow, tensorflow, keras, creating a new environment, installing with pip and repeated this in about every location I can think of but this issue remains persistent. Any help would be greatly appreciated.
Thank you
One solution that might work for your case:
First, you need to : pip install pillow (uninstall + reinstall / upgrade it it's the case)
Second, you need to change your imports in this way:
from IPython.display import display
from PIL import Image
This solution can be found in the following thread:
ImportError: Could not import the Python Imaging Library (PIL) required to load image files on tensorflow

DLL load failed: The specified module could not be found

I have installed Python 3.6.4. When I import cv2, it throws this error:
DLL load failed: The specified module could not be found.
I have OpenCV version 2.4.13.
What should i do?
It's possible that you have Python 2 and 3 installed and Python 3 doesn't know about your opencv installation. Try this:
pip3 install opencv-python
That will install opencv for Python 3 and hopefully that fixes your problem.
Try doing this:
Go to command prompt and "cd" the directory of python.
Enter this if you are running Python 3.x.x
pip3 install opencv-python
OR
2.If on Python 2.x.x
pip2 install opencv-python
DO NOT USE:
pip install opencv
That was my mistake and had to dig a lot to find a solution.
In my situation,
ImportError Traceback (most recent call last)
in ()
10 import os.path
11 from keras.models import load_model
---> 12 import cv2
13 from utils.utils import get_yolo_boxes, makedirs
14 from PIL import Image
ImportError: DLL load failed: The specified module could not be found.
Face this ImportError in the pass week, and I solved with enter below scripts in the Anaconda Prompt.
conda install -c menpo opencv
And here is my environment:
Python 3.6.5 Anaconda
Keras 2.2.2
tensorflow 1.9.0
For more details, here is the log I tried to solved this ImportError:
micky619/holiday-similarity#3
This can happen if you are using windows 10 N distribution, the N distributions does not come pre installed with windows media feature pack, which is required after OpenCV version 3.4 and onwards.
The preferred solution is to install the feature pack at : https://www.microsoft.com/en-us/software-download/mediafeaturepack
Be careful to choose the version that works with your current version of windows.
If that is not an option, fall back to an earlier version of OpenCV that does not have dll dependencies, you can do that by:pip install opencv-python=3.3.0.9
If the problem still persists try using Dependency walker to find out where specifically your problems stem from and then try fixing them individually.
Since windows rolled out it's N version this problem has been seen at many places, and has many impacts across the windows environment, the fastest way to identify if you have this problem is open youtube in Edge browser, if it says HTML5 media plugin not found, this is the problem.

I am using Pillow and getting an error "ImportError :No module named Image" in Ubuntu?

Does anyone know why I am getting this error?
I have Ubuntu 32-Bit , and Python 32-Bit and Installed Pillow using pip
Here is the code:
import Image
import pytesseract
print pytesseract.image_to_string(Image.open('1.jpg'))
Here is the error :
Traceback (most recent call last):
File "/home/siamak/workspace/test/com/tower/test/ocr.py", line 1, in
import Image
ImportError: No module named Image
You have to do:
from PIL import Image
Image is a submodule of PIL, so you have to use the from...import syntax.
I tested it on Linux Mint , and CentOS and it works perfectly .
For some reason it doesn't work on Ubuntu 32 and 64 .
I am assuming it is related to the PIL installation
Thanks
I also had this problem where,
from PIL import Image
gave this same error as the one in your comment:
from PIL import _imaging as core
ImportError: /home/jer/.local/lib/python2.7/site-packages/PIL/_imaging.so:
undefined symbol: PyUnicodeUCS4_AsLatin1String
It seems a locally installed version of Pillow is the culprit. We can uninstall the local version with,
pip uninstall Pillow
This left the system version of Pillow installed, which worked fine.

opencv 2.4.8 is not importing

As i am doing background subtraction on a video, opencv 2.4.6 is not supporting, like web cam will not respond.
my guide suggested me to download and install opencv 2.4.8, and i did so, but it is giving me an error
ImportError
<ipython-input-1-72fbbcfe2587> in <module>()
----> 1 import cv2
ImportError: numpy.core.multiarray failed to import
i have uninstalled the earlier version and then i have installed the new version, and done all the prerequisites.
Thank you for the support!
OpenCV relies on numpy, do you have numpy installed?

Categories

Resources