I am building a Python web scraping script and i have to use cv2 (OpenCV). So I install using pip install opencv-python as the website directs. And it also installs numpy as a dependency.
However, right after installing that, I'm unable to run my python script. It crashes with the error below:
I think the issue is from Numpy but I don't know how to fix this. Please help.
This is my environment:
MacOS 10.15.7
Python 3.9.0
pip 20.2.4 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
Numpy 1.19.2
opencv-python 4.4.0.44
I had the same issue when I tried to run a project I made on Windows on Mac OS. The solution I found was to install an older version of numpy (e.g. numpy 1.18).
Here is the command I ran to do so :
sudo python -m pip install numpy==1.18 --force
I don't think it is a good solution but it is ok for a temporary fix.
Related
I am currently on Linux x86-64 machine. I am trying to install opencv in my virtual environment using pip however the error I keep receiving is
ERROR: Could not find a version that satisfies the requirement numpy==1.19.3 (from versions: 1.19.2+computecanada, 1.21.0+computecanada, 1.21.2+computecanada)
ERROR: No matching distribution found for numpy==1.19.3
I am running python 3.9.6 (64bit) and my current numpy version is 1.21.3. the command I've been using is pip install opencv-python. i've also tried uninstalling other instances of openCV and have tried the other options all with the same error. Does openCV not support numpy 1.21.3? Would anyone be able to point me in the right direction?
On computecanada you don't need to install OpenCV.
You can use it by following these commands:
module spider opencv
module load opencv/version
Actually, this error happens if numpy version does not match OpenCV required version.
for my case:
I used python 3.6. so I solved this error by following:
pip install numpy==1.19.0
pip install opencv-python==3.4.11.45
after installing numpy I search which OpenCV version support this numpy version, I found 3.4.11.45 so I install it by 2 number command and it is working.
The Mac Book Air M1 chip doesn't seem to support pep517 according to the errors of installing third-party libraries with pip or brew. Even using these methods without pep517 downloading the library locally didn't work. How does one circumvent this?
Error from using pip install pandas:
Failed to build numpy
ERROR: Could not build wheels for numpy which use PEP 517 and cannot be installed directly
I've tried this:
pip install <lib>
installing the library locally and trying to install with pip without pep517
brew install <lib>
openblas installation of lib
python env on the intel venv
I had the exact same problem, with a different library but with the same error code for PEP 517, I was using python 3.9 at the time, I checked the docs and found out that it's a problem with the python version for the library, downgraded to Python 3.6 and voila! it worked.
Basically try downgrading to Python 3.6 and check.
Installing python libraries through Anaconda seems to work. I simply downloaded the installer and could later use the libraries globally. If someone has a better in-depth explanation, feel free to comment.
I was having the same message when trying to install a different package. I solved by removing the CommandLineTools and installing it again. The steps were:
sudo rm -r /Library/Developer/CommandLineTools
wait for command prompt...
xcode-select --install
This solved the issue for me.
I did find this question asked by few more people, but none of those exactly met my situation, so asking here myself.
I've (rather had) two versions of Python (2.7 and 3.4.3) on my Mac running the latest MacOS High Sierra. As I understand, the v2.7 comes as default installation with the MacOS. And I installed the 3.4.3 (from .dmg file downloaded from the python site). Thus now, the python command defaults to the 2.7, while python3 points to the 3.4.3 in the terminal.
While trying to learn, I tried a python script that uses
import PIL and from PIL import Image
But when running, this gave the error ImportError: No module named PIL.
Upon research on google, I figured out to install PIL and Pillow using
sudo pip install Pillow
It installed correctly, but I'm still getting the same error.
To remove the confusion, I decided to remove the python 3.4.3 from the system. But even after it's removed, I still get the same error.
Even pip list displays Pillow 5.1.0 alright.
So right now, I've only Python 2.7, and the error persists, while Pillow is also in there.
which python gives /opt/local/bin/python as the path.
Does any of the above ring a bell? Any ideas, what else could be missing here?
Phew, finally found the issue. Thanks #Yash for the pointers.
Incidentally I did a which -a python and surprisingly got this output:
/opt/local/bin/python
/usr/bin/python
Damn, I don't remember when I installed a second 2.7 version on the /opt/local/bin folder (probably via macports). Alright, removed the confusion, deleted this python, so now I'm left only with the system installed python at /usr/bin.
And now the imports all run perfectly fine as expected. :-)
Try this,
sudo pip install image
I hope it works! One more thing, do check if you're running python3 filename.py instead of python filename.py, if you want to install it for Python 3, run the command,
sudo pip3 install Pillow
Basic Installation:
pip install Pillow
Windows Installation:
pip install Pillow
Reference: https://pillow.readthedocs.io/en/stable/installation.html
Try this. It worked for me
pip install --upgrade --force-reinstall pillow
If you get something like access denied error run the below command
pip install --upgrade --force-reinstall pillow --user
I used following process to install:
Download & install 64-bit Python: https://www.python.org/downloads/release/python-342/
Download the 64-bit version of numpy:
pip install "numpy-1.9.2rc1-cp34-none-win_amd64.whl"
pip install pandas==0.14.0
Error message is attached.
Thank you for help.
enter image description here
When you intstall pandas it will automatically install numpy so need to install numpy seperately, also you need to have microsfit visual basic C++ 10.0.
I had the same case and when I installed it everythig went fine.
I installed opencv via the command pip install opencv-python and then when I import cv2 in python I get the error ImportError: dlopen(/Library/Python/2.7/site-packages/cv2/cv2.so, 2): Symbol not found: _clock_gettime
I would like to install opencv for python 2.7 on a mac. How can I resolve this error ? I am using El Capitan.
I installed opencv prior to this using brew install opencv but then I uninstalled it using brew uninstall opencv before using pip.
This works !
sudo pip install opencv-python==3.3.0.10
El Capitan has an issue detailed here http://answers.opencv.org/question/182067/import-cv2-throws-symbol-not-found-_clock_gettime/
In order to circumvent this issue, I rolled back to an earlier version of opencCV.
A trick to check the available version with pip do
sudo pip install opencv-python==
This will return all the available version and then you can try the ones that work for you.
Dont forget to pip uninstall when moving to a different version
It looks like this is an issue with python-opencv and the mac operating system That you are using. From the link below it looks like Apple changed something to do with _clock_gettime function, meaning the maintainers of python-opencv will need to update.
The commenters on the post below managed to fix the issue by upgrading to Sierra
http://answers.opencv.org/question/182067/import-cv2-throws-symbol-not-found-_clock_gettime/