Yesterday it seems like my OpenCV is working fine, but today when I reinstall and hit repair the python that I was using. I can't access import cv2 anymore. I tried to reinstall python and reinstall OpenCV but it's not working too. How can I fix this? When I import cv2 at cmd it seems to be working (cmd screenshot) but when I used python at the visual studio 2019 it says "no module named cv2" visual studio screenshot. How can I fix this? Please help.
If you're using Python 2 enter the following:
pip show opencv-python
If you're using Python 3 enter the following:
pip3 show opencv-python
Can you see information about opencv-python package? (name, version, summary..etc)
If yes then ensure Python is added to PATH and you're running the Python version where the opencv package is installed.
If no then you didn't install opencv-python.
If you're using Python 2 enter the following:
pip install opencv-python
If you're using Python 3 enter the following:
pip3 install opencv-python
Related
I have downloaded Anaconda on my Windows PC, and I have been using Spyder IDE. Now I want to do a project with OpenCV.
However, I have tried to install OpenCV using the Command Prompt and typing the following in:
pip install opencv-python
This only gives an error message and says "pip" is not recognized as a command.
Furthermore I tried to import OpenCV into Python using the following:
import cv2
This also doesn't work
I would appreciate any help in getting OpenCV working.
It depends on Your OS. Check Your pip installation with cmd: pip -V and check python with: python -V
It seems like You don't have pip installed at all.
Than import cv2 should work.
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've created a project in Pycharm IDE. I've used python 3.5, tensorflow library. Now I want to install opencv in this.
I have tried so many videos available on youtube and some tutorials in the internet. But when import open cv in python shell it gives me following error. How can I fix it?
import code
import cv2
Error message
Traceback (most recent call last):
File "", line 1, in
import cv2
ImportError: Module use of python27.dll conflicts with this version of Python.
I have noticed that python 2.7 is used to install opencv. Is it a must o use 2.7 version?
Also as I know tensorflow will not support if I use another version of python(other than 3.5)
You can try using
python -m pip install opencv-python
This method uses the unofficial OpenCV PyPi wheels for Linux, Mac and Windows
Did you download open cv for Python 3? Try this:
Make sure you have numpy installed
Download open cv for Python 3 from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv
(not sure if this will work with Python 3.5, should work with 3.2)
Run pip install opencv_python-your_verison_here.whl
Since PyCharm is tagged I'm assuming you are wanting to know how to get opencv installed in PyCharm specifically. There is a PyCharm guide for installing packages here.
Step by step would be...
File | Settings | Project:MyProject | Project Interpreter
Click the + symbol on the right
Type opencv-python
Select opencv-python
Click Install Package at the bottom left
Opencv should now be added to PyCharm. You can verify that it is by...
Tools | Python Console...
Clicking in the console window which pops up on the bottom
import cv2
There are a lot of suggestions on how to solve this, but this was actually very easy to solve when using Anaconda. The problem is not the Visual C++ 2015 redistribution, but rather the python3.dll which is missing from
C:\Users\username\AppData\Local\Continuum\Anaconda3 as your second link suggests.
A lot of these sites suggests downloading it manually, but according to this thread ContinuumIO/anaconda-issues#1394 the most recent anaconda packages should all include the missing python3.dll file. So by updating python with conda, this was solved:
**conda update python**
try typing this into your terminal :
pip install opencv_python.
This worked for me.I have Python 3.5.2.
My objective is to use OCR in Python 2.7 using Tesseract on a Windows 7 machine, but I am running into issues as for the installation process. I tried following the instruction here but the link to "tesseract-core-yyyymmdd.exe" and "tesseract-langs-yyyymmdd.exe" do not exist anymore and I can't find these .exe elsewhere online. Here's what I have done so far:
installed tesseract from its executable from official tesseract-ocr page.
installed via pip packages "wand", "PIL", "pyocr".
Now, if I do the following in Python:
from wand.image import Image
from PIL import Image as PI
import pyocr
import pyocr.builders
import io
No problem loading up these packages but pyocr.get_available_tools() gives me an empty list. I am sure this has to do with the missing installation .exe files above. Where can I find them? Is it something else that I am missing?
I just tried to set up pytesseract and it works ! I have windows 10 and python 2.7 installed.
all you need to do :
Download Visual basic C++ from http://aka.ms/vcpython27 and install it (common installation step)
Download tesseract from python via this link https://pypi.python.org/pypi/pytesseract
Unizip the file.
Go to the directory which contains the unizip file
Run this command " python setup.py install "
(Additional) to test if it's installed, go to your python shell and run this command " import pytesseract "
I hope it works !! Note pytesseract is google based OCR, it works similarly to tesseract.
Step [1] To install tesseract kindly visit
https://github.com/UB-Mannheim/tesseract/wiki
The latest installers can be downloaded from here:
e.g., tesseract-ocr-setup-3.05.02-20180621.exe, tesseract-ocr-w32-setup-v4.0.0-beta.1.20180608.exe, tesseract-ocr-w64-setup-v4.0.0-beta.1.20180608.exe (64 bit)
Step [2] Download Microsoft Visual C++ Compiler for Python 2.7 from the link given below
https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi
Step [3] Install pytesseract for binding for tesseract using pip
pip install pytesseract
Step [4] Furthermore you can install an image processing library in python, e.g., pillow:
pip install pillow
greetings!! you are done!! :)
PIP is a package manager for Python packages
Open cmd run pip search "pytesseract", you can see latest version
Run pip install pytesseract for latest version or pip install pytesseract==0.3.0 for version you want.
In windows python cmd run import pytesseract for sure installed was successful.
Install both and you are done
Binaries from:
https://github.com/UB-Mannheim/tesseract/wiki
Python Wrapper from here:
https://pypi.python.org/pypi/pytesseract
I am trying to install opencv in python on my windows machine but I am unable to do so. I have python 2.7.11::Anaconda 2.4.1 <32-bit>
Here is what I have tried till now -
pip install cv2 on command line gives the error :
could not find a
version that satisfies the requirement cv2
I downloaded the package from sourceforge site, followed the steps
and pasted cv2.pyd in C:\Python27\Lib\site-packages but still it is
not working. I get the following error message
ImportError: No
module named cv2
(I already have numpy installed and it works just fine).
pip install opencv-python
you can type this instead of
pip install cv2
it also works with anaconda pro
I was able to solve the error.
If you are using python version 3 , sometimes you have to use pip3.
pip3 install opencv-python
Make sure you are using python 3 , it won't work for python 2.
Try
pip install opencv-python==4.3.0.36
So I was using PyCharm, and what worked for me was to install it directly from file->settings, Project:your-project-name->Python Interpreter list