Reputation: 165
I used to use anaconda, but currently I tried Pycharm and then I fall in love with it.
Now I have a project from my master degree, one of the module I have to use, is opencv.
But sadly I can't install open cv on my Mac machine correctly,
it keep returned me, this error
Collecting opencv
Could not find a version that satisfies the requirement opencv (from versions: ) No matching distribution found for opencv
Upvotes: 0
Views: 3670
Reputation: 3115
For installing OpenCV on Mac and using it in PyCharm, follow these steps:
Prerequisites: Python 2.7 or 3xx, virtualenv and OpenCV installed.
Open a terminal and create a virtual environment, pyimagesearch
here
$ mkvirtualenv pyimagesearch
Step 2 is miscellaneous, depending on your needs.
pip install numpy
pip install scipy
pip install matplotlib
Sym-link your cv2.so and cv.py files. (only cv2.so files for OpenCV 3xx ).
On my system, OpenCV is installed in /usr/local/lib/python/2.7/site_packages/
$ cd ~/.virtualenvs/pyimagesearch/lib/python2.7/site-packages/
$ ln -s /usr/local/lib/python2.7/site-packages/cv.py cv.py
$ ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so
These steps are essentially for setting up this virtual environment for PyCharm.
Open up PyCharm and create a new "Pure Python" project
Set up the location of our Python Interpreter. By default, PyCharm will point to the system install of Python, however, for our case we need it to point to the virtual environment pyimagesearch
.
So click on the gear icon and select "Add Local". In my case, the pyimagesearch
virtual environment is located in ~/.virtualenvs/pyimagesearch/
with the actual Python binary in ~/.virtualenvs/pyimagesearch/bin
. Once you have successfully navigated to your folder, choose the virtual environment binary which is python2.7
in the bin folder for me.
Hope it helps!
After this, you are all set. PyCharm will use your pyimagesearch
virtual environment and will recognize the OpenCV library.
Upvotes: 1