When I try to use from PIL import ImageGrab it gives me this error:
ModuleNotFoundError: No module named 'PIL'
I installed it with pip install pillow and checked if it is installed with pip show pillow. It says I have Version: 8.1.2
I am using python 3.9 and sublime text 3
In the internet I saw most people with that problem have a not maching python version with the pillow version, but mine should work as far as I understood..? (https://pillow.readthedocs.io/en/stable/installation.html)
However its not working and I am trying to fix this since about two hours and I hope somebody can help me.
You might have different versions of python installed and pip is installing pillow for a different version.
A good way to avoid this is using python -m pip install pillow instead of pip install pillow.
Try to install it with pip3 install pillow
The fact is that you installed it for python2 but your are using python3 ;)
I tried to install OpenCV in so many ways. I tried this tutorial:
https://docs.opencv.org/master/d0/db2/tutorial_macos_install.html
I tried using conda:
conda install -c conda-forge opencv
etc. etc.
But when I type in import cv2 it says:
PyCharm Image OpenCV
Does somebody have an idea?
To install opencv you can either build it with CMake (like the link you tagged) or install a pre-built version of it (easier).
You can do the pre-built via PyCharm going to your project settings and adding the 'opencv-python' package or running pip install opencv-python
If you need both main and contrib modules you can install 'opencv-contrib-python' instead
Here's the package's page: https://pypi.org/project/opencv-python/
These are the things I tried but nothing seems to work yet
pip install opencv-python
OR
python -m pip install opencv-python
gives an error
ERROR: Could not find a version that satisfies the requirement opencv-python (from versions: none)
ERROR: No matching distribution found for opencv-python
I downloaded the opencv windows package from the site and copied the PYD file into python's site-packages
but still cv2 cannot be imported
import cv2
gives an error as
DLL load failed while importing cv2: %1 is not a valid Win32 application.
Then I downloaded the opecv-control WHL file for python3.8/32bit (as my python is 32 bit) unofficial Binaries for python extension packages
and followed the step but still nothing happened
I am a beginner in this.
OpenCV hasn't been built for 3.8 yet according to the docs 3.7 is the highest version
https://pypi.org/project/opencv-python/
try downgrading your python to 3.7 or below. It would work.
Is pip up to date? You can run python -m pip install --upgrade pip to check.
It should work after that.
Please try the following:
import imp
imp.find_module("cv2")
Python Package Link
In the above link search opencv_python‑4.1.2‑cp36‑cp36m‑win_amd64.whl for python 3.6
64 bit and download that wheel file.
Install procedures:
Go to the site-package path in the python36
C:\Program Files\Python36\Lib\site-packages>
Then put the command pip install . Example,
C:\Program Files\Python36\Lib\site-packages>pip install F:\urllib3-1.25.7-py2.py3-none-any.whl
After this procedure import and check in IDLE.
If any doubt ping this. Good luck
I've been beginning to work with images in Python and I wanted to start using PIL (Pillow). To install it, I ran pip install Pillow. When installing, PIL was not previously installed. I also tried uninstalling it and reinstalling it, as well as using pip3 install Pillow.
When I run it in Python, my first line is:
File "C:\Program Files\Python36\lib\site-packages\PIL\Image.py", line 56, in <module>
from . import _imaging as core
ImportError: DLL load failed: The specified procedure could not be found.
I checked the directory, and the file _imaging.cp36-win_amd64.pyd is present under the PIL folder.
Why is this happening if the needed DLL is there? How can I fix it?
I had this problem as well with Python 3.6. I just avoided the problem by uninstalling pillow (4.1.0) and then installing an older version of pillow (4.0.0). It seems to run okay with the older version.
As in Sean's answer, I had to uninstall (I'm using Anaconda Python 3.6, BTW) with
conda uninstall pillow
I tried it with PIL, but there was no such package. Uninstalling pillow also meant uninstalling packages that depend on it, in my case "anaconda-navigator" and "scikit-image". After I reinstalled Pillow 4.0.0 with
conda install pillow=4.0.0
and tested it with
python -c "from PIL import Image"
which, if successful, you don't see an error message, I reinstalled the packages that were uninstalled along with Pillow 4.1.0.
conda install anaconda-navigator
conda install scikit-image
If you're using Anaconda, try
conda uninstall pillow and then pip install pillow
Came across this issue while working on Caffe2 on Windows 10 (Anaconda 4.5) and this worked for me. Here's the github post on this issue.
This problem is also fixed by upgrading Python to 3.6.1, per this GitHub discussion.
The difference is that Pillow 4.1.0 was built with Python 3.6.1 while Pillow 4.0.0 was built with Python 3.6.0.
Apparently PYTHON36.DLL from Python 3.6.0 is missing functions (PySlice_AdjustIndices and PySlice_Unpack) that are used when building with Python 3.6.1.
The solution is to upgrade to Python 3.6.1.
There's a problem in Python itself which means binary wheels build using Python 3.6.1 (like Pillow 4.1.0) won't install on Python 3.6.0.
This has affected a number of Python libraries.
However, there's the new Pillow 4.1.1 release works around this, so you can now update to Pillow 4.1.1 and use it with both Python 3.6.0 and 3.6.1.
More info:
https://github.com/python-pillow/Pillow/issues/2479
https://mail.python.org/pipermail/python-dev/2017-March/147707.html
https://bugs.python.org/issue29943
for new people 2022
i solved it
you can look at this
https://pillow.readthedocs.io/en/latest/installation.html
if PIL dont want to uninstall delete or cut it to another folder
This works for me using win10 and py 3.6.
Simply uninstall Pillow 4.1.0
pip3 uninstall Pillow
Then install Pillow 4.0.0
pip3 install Pillow==4.0.0
I had the same problem with anaconda 5.0.1, using it with caffe on windows 10. i just did
conda install PIL
it worked for me.
Seems like some issue is there with tensorflow 1.12.0 +Python 3.6.0 + win10
Working fine with conda tensorflow.
below steps worked for me for pip tensorflow.
uninstall tensorflow
replace your python version with 3.6.1
install latest version of tensorflow(1.13.0)
For installing Tensorflow follow below link:-
https://www.tensorflow.org/install/pip
If you are a Windows user and do not have Microsoft Visual C++ the error occurs. I got the same error and resolved this by installing the Microsoft Visual C++. Link for downloading can be found here.
https://support.microsoft.com/en-us/topic/the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0
First uninstall existing version
pip uninstall pillow
Then try installing
pip install pillow==4.0.0
I've been trying to install both OpenCV and cv2 from both Pycharm and from the terminal as suggested using:
pip install --user opencv
pip install --user cv2
but I'm getting the following error for them:
Collecting opencv
Could not find a version that satisfies the requirement opencv (from versions: )
No matching distribution found for opencv
and
Collecting cv2
Could not find a version that satisfies the requirement cv2 (from versions: )
No matching distribution found for cv2
How can I fix these and install the packages properly? I'm using python 3.4.
You are getting those errors because opencv and cv2 are not the python package names.
These are both included as part of the opencv-python package available to install from pip.
If you are using python 2 you can install with pip:
pip install opencv-python
Or use the equivilent for python 3:
pip3 install opencv-python
After running the appropriate pip command your package should be available to use from python.
This the correct command that you need to install opencv
pip install opencv-python
if you get any error when you are trying to install the "opencv-python" package in pycharm, make sure that you have added your python path to 'System Variables' section of Environment variables in Windows.
And also check whether you have configured a valid interpreter for your project
I ran into the same problem. One issue might be OpenCV is created for Python 2.7, not 3 (not all python 2.7 libraries will work in python 3 or greater). I also don't believe you can download OpenCV directly through PyCharm's package installer. I have found luck following the instructions: OpenCV Python. Specifically:
Downloading and installing OpenCV from SourceForge
Copying the cv2.pyd file from the download (opencv\build\python\2.7\x64) into Python's site-packages folder (something like: C:\Python27\Lib\site-packages)
In PyCharm, open the python Console (Tools>Python Console) and type:import cv2, and assuming no errors print cv2.__version__
Alternatively, I have had luck using this package opencv-python, which you can straightforwardly install using pip with pip install opencv-python
Good luck!
python3.6 -m pip install opencv-python
will install cv2 in python3.6 branch
On Windows:
!pip install opencv-python
Try this. I am using Jupyter notebook (OS: Ubuntu 16.04 LTS on Google Cloud Platform + on Windows). Executed following command in the Jupyter notebook to install opencv:
!pip install opencv-contrib-python #working on both Windows and Ubuntu
After successful installation you will get following message:
Successfully installed opencv-contrib-python-4.1.0.25
Now restart the kernel and try to import opencv as:
import cv2
The same command can be used to installed opencv on Windows as well.
SOLUTION 2: try following commands to install opencv:
For Ubuntu:
Run following command from terminal:
sudo apt-get install libsm6 libxrender1 libfontconfig1
Restart Jupyter notebook kernel and execute following command:
!pip install opencv-contrib-python
NOTE: You can run all the above commands from the terminal as well without using '!'.
Keep it simple and just run.
pip install opencv-python
This is the simplest way of installing opencv.
If you still face issue, create a virtual environment and try installing opencv.
I rather use Virtualenv to install such packages rather than the entire system, saves time and effort rather than building from source.
I use virtualenvwrapper
Windows user can download
pip install virtualenvwrapper-win
https://pypi.org/project/virtualenvwrapper-win/
Linux follow
pip install opencv-python
opencv-python
If processing a video is required
pip install opencv-contrib-python
opencv-contrib-python
If you do not need GUI in Opencv
pip install opencv-contrib-python-headless
opencv-contrib-python-headless
here is a tutorial that worked for me without any problem.
Copied from the site above the important part:
Download the OpenCV version corresponding to your Python installation
from here. In my case, I’ve used
opencv_python-3.1.0-cp35-cp35m-win32.whl.
Now, open a cmd window like before. You can open this directly in your
Downloads folder if you SHIFT and right click inside it. The idea is
to open a cmd window where you’ve downloaded the above [...] file. Use
the [...] command to install [...] OpenCV:
1 pip install "opencv_python-3.1.0-cp35-cp35m-win32.whl"
Additional note: don't forget to change the name of the downloaded file in the command you use.
Apparently by installing opencv, you'll have access to cv2 too.
Installing opencv is not that direct.
You need to pre-install some packages first.
I would not recommend the unofficial package opencv-python. Does not work properly in macos and ubuntu (see this post). No idea about windows.
There are many webs explaining how to install opencv and all required packages.
For example this one.
The problem of trying to install opencv several times is that you need to uninstall completely before attempting again, or you might end having many errors.
you must install opencv-python
pip/pip3 install opencv-python
if you try import opencv-python, receive error.
Fix this error, use the import cv2
How about try some different mirrors?
If you are in China, I highly recommend you try:
sudo pip install --index https://pypi.mirrors.ustc.edu.cn/simple/ opencv-contrib-python
If not, just replace the url address to some other mirrors you like!
Good luck.
this will help you
pip3 install opencv-python
this is the snippet of successful installation
First step:
pip uninstall numpy
pip uninstall opencv-python
Second step:
pip install numpy
pip install opencv-python
I had the same problem. Here are the steps for Windows 10 users.
Open CMD: win+r then type cmd. Now,
Type pip install virtualenv
Create a Virtual Environment, Type virtualenv testopencv
Get Inside testopencv, Type cd testopencv
Activate the Virtual Environment, Type .\Scripts\activate
Now Install Opencv, Type pip install opencv-contrib-python --upgrade
Let's test Opencv, Type Python then import cv2 hit enter then type print(cv2.__version__) to check if its installed
Now, open a new cmd, win + r then type cmd, repeat step 6. If it gives you an error.
Go inside the testopencv folder, inside lib. Copy everything, go to your python directory, inside lib folder paste it and skip that are already present.
Again open a new cmd, repeat Step 6.
Hope it helps.
In win, download the py based latest numpy and Opencv from Unofficial Windows Binaries for Python Extension Packages and pip install its source in cmd. Later copy site-package folder from main py lib to venv lib.
In jetso nano this work for me.
$ git clone https://github.com/JetsonHacksNano/buildOpenCV
$ cd buildOpenCV
When I was facing this issue I used to install OpenCV in pycharm installed package panel where we can find under the settings tab. Search "OpenCV-python" and install it in the installed package panel of right interpreter.
First run from cmd
pip --version
to make sure that you have the updated version installed.
Then run
pip install opencv-python
Go through with this link: https://learnopencv.com/install-opencv-4-on-raspberry-pi/
you can install OpenCV perfectly with out any error. but the problem was it will take lot of time to install.
I had used pi3 model B+ with 32GB class10 SD card for me it took more than 12 hours for complete installation.
If you still find any error to install open-cv in your mac, try this:
opencv-python==4.2.0.34
This worked for me.