I am importing Image, ImageTk using from PIL import Image, ImageTk
I get the error that the module doesnt exist, but when I try to install it, it says that the module is already installed.
I get this error:
from PIL import Image, ImageTk
ModuleNotFoundError: No module named 'PIL'
When I try to import pillow using pip install pillow I get the following message.
Requirement already satisfied: pillow in c:\users\admin\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (9.2.0)
This is on VS code, so I suspect the python interpreter.
I hope this will help you:
👇️ Before installing Pillow, uninstall PIL.
pip uninstall PIL
👇️ in a virtual environment or using Python 2
pip install Pillow
👇️ for python 3 (could also be pip3.10 depending on your version)
pip3 install Pillow
👇️ if you get permissions error
sudo pip3 install Pillow
pip install Pillow --user
👇️ if you don't have pip in your PATH environment variable
python -m pip install --upgrade Pillow
👇️ for python 3 (could also be pip3.10 depending on your version)
python3 -m pip install --upgrade Pillow
👇️ using py alias (Windows)
py -m pip install --upgrade Pillow
👇️ for Anaconda
conda install -c conda-forge pillow
👇️ for Jupyter Notebook
!pip install Pillow
Make sure that the interpreter environment you are currently using and the interpreter environment where the pillow package is installed are the same.
Ctrl+Shift+P --> Python:Select Interpreter
Choose the right interpreter
I keep getting the same error when I try to run manage.py runserver:
Cannot use ImageField because Pillow is not installed.
I have seen several threads made by people that have encountered the same problem but none of them have a straightforward fix to this issue. I have already installed Pillow (pip install Pillow and pip3 install Pillow). I have uninstalled it several times, and reinstalled it. But whenever I run my server it says that Pillow is not installed.
I am on Windows 10. Any help would be appreciated.
FIXED! I removed all paths and made two new ones in my environment variables. It works now.
Try this to install or if you have already try to upgrade
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow
try importing package like this..
>>> from PIL import Image
Refer to official docs
I have tried to install PIL, however unsuccessfully.
I used the commands:
pip install pillow
sudo pip3 install pillow
And yet python didn't recognize PIL.
Any solutions to this problem ?
You might be having PIL already installed which may be conflicting. Go to your python packages and manually delete pillow, Pillow, PIL etc and reinstall using pip install pillow
You say that it worked once and then later does not. A mistake that I have made more than once is naming a script that I am writing pil.py, and then wondering why I can't import PIL. So that could be an explanation.
If the installation is truly the problem though, here are some alternatives.
You could try python3.6 -m pip install Pillow - it does the same thing, but you never know.
You could try downloading the source code of Pillow - https://github.com/python-pillow/Pillow/releases - and running python3.6 setup.py install to install it directly. This will likely fail to lack of other requirements, but again, just giving ideas.
If you're on Linux, you could try your relevant package manger - apt install python3-pil for Ubuntu, etc.
I'm new to Python and I have a problem with Pillow (as many people before me).
Running the command below:
from PIL import Image
causes a known error:
ModuleNotFoundError: No module named 'PIL'
The problem occurs when I try to run it with Python 3.6, everything works fine with Python 3 however I have to use version 3.6 in my project.
Pillow version: 4.3.0, so it is compatible with this Python version.
Why does this not work on the newer version?
I had to install pillow for 3.6 python: python3.6 -m pip install pillow
PIL and Python compatibility issue. See for example (http://pillow.readthedocs.io/en/5.1.x/installation.html ).
pipX search Pillow -> shows which version is installed and available.
Better to use Python virtual environment to avoid compatibility issues.
pip uninstall Pillow
pip uninstall PIL
pip install Pillow
Source
C:\python>pip install pillow
Collecting pillow
Downloading https://files.pythonhosted.org/packages/4e/d9/468422371e6fcf02d6a162ee30db4552221de8b2b3ff837363bf54cbb347/Pillow-6.1.0-cp36-cp36m-win_amd64.whl (2.0MB)
100% |████████████████████████████████| 2.0MB 3.2MB/s
Installing collected packages: pillow
Successfully installed pillow-6.1.0
You are using pip version 18.1, however version 19.2.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
The single line that I am trying to run is the following:
from PIL import Image
However simple this may seem, it gives an error:
Traceback (most recent call last):
File "C:\...\2014-10-22_12-49.py", line 1, in <module>
from PIL import Image
File "C:\pyzo2014a\lib\site-packages\PIL\Image.py", line 29, in <module>
from PIL import VERSION, PILLOW_VERSION, _plugins
ImportError: cannot import name 'VERSION'
In case that's helpful, I installed pillow from https://pypi.python.org/pypi/Pillow/2.6.1 (file Pillow-2.6.1.win-amd64-py3.4.exe) before running this (before that there was already som PIL install, which I uninstalled). The script is run in Pyzo with Python version 3.4.1.
What is going wrong, how can I import Image?
I had the same error. Here was my workflow. I first installed PIL (not Pillow) using
pip install --no-index -f https://dist.plone.org/thirdparty/ -U PIL
Then I found Pillow and installed it using
pip install Pillow
What fixed my issues was uninstalling both and reinstalling Pillow
pip uninstall PIL
pip uninstall Pillow
pip install Pillow
I had the same issue, and did this to fix it:
In command prompt
pip install Pillow ##
Ensure that you use
from PIL import Image
I in Image has to be capital. That was the issue in my case.
FWIW, the following worked for me when I had this same error:
pip install --upgrade --force-reinstall pillow
For me, I had typed image with a lower case "i" instead of Image. So I did:
from PIL import Image NOT from PIL import image
If you use Anaconda, you may try:
conda install Pillow
Example
All the answers were great however what did it for me was a combination of uninstalling Pillow
pip uninstall Pillow
Then installing whatever packages you need e.g.
sudo apt-get -y install python-imaging
sudo apt-get -y install zlib1g-dev
sudo apt-get -y install libjpeg-dev
And then using easy_install to reinstall Pillow
easy_install Pillow
Hope this helps others
Install Pillow from Command Line:
python -m pip install pillow
The current free version is PIL 1.1.7. This release supports Python 1.5.2 and newer, including 2.5 and 2.6. A version for 3.X will be released later.
Python Imaging Library (PIL)
Your python version is 3.4.1, PIL do not support!
In Ubuntu OS, I solved it with the followings commands
pip install Pillow
apt-get install python-imaging
And sorry, dont ask me why, it's up to me ;-)
had the same error while using pytorch code which had deprecated pillow code. since PILLOW_VERSION was deprecated, i worked around it by:
Simply duplicating the _version file and renaming it as PILLOW_VERSION.py in the same folder.
worked for me
I had the same problem, pillow was installed with an environment.yml in anaconda
I am quickly learning that pip and setuptools must always be up to date or I will have problems. Always update these tools before installing packages.For any package import problem uninstall the package upgrade the listed tools(maybe even your base environment) and reinstall.
conda uninstall pillow
python -m pip install pip --upgrade
pip install setuptools --upgrade
pip install pillow
If using Anaconda, from the base environment first run the following before installing packages/environments:
conda update conda
Updating the base env is not required to fix this issue but is a good practice to avoid similar problems
#theeastcoastwest touched on the pip upgrade in their answer but I felt more information was needed
If you've got different Python versions, be sure to install it with the version, you start the script:
python3.9 -m pip install pillow --upgrade
After a lot of googling and different solutions, this is the most efficient, I found.
I am also facing same error, just try to uninstall and resinstall
#uninstall and resinstalltion cmds
pip uninstall pillow
pip uninstall PIL
pip install pillow
Pillow installation link basics link
Using jupyter note book do this below follwing installationa and verified the code as shown below
pip install pillow
#(or)
pip install PIL
import PIL
print(PIL.__version__)
'8.4.0'
(Or) You are using command prompt installation then follow below instruction for windows. Personally suggest this below method.
Microsoft Windows [Version 10.0.19043.1348]
(c) Microsoft Corporation. All rights reserved.
>pip install pillow
Requirement already satisfied: pillow in c:\users\admin\appdata\roaming\python\python310\site-packages (9.0.0)
>python
Python 3.10.1 (tags/v3.10.1:2cd268a, Dec 6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL
>>> (PIL.__version__)
'9.0.0'
>>> quit()
do from PIL import Image, ImageTk
If you did all and it didn't work again like mien, do this
copy Image.py and ImageTk.py from /usr/lib/python3/dist-packages/PIL on ubuntu and C:/Users/yourComputerName/AppData/Local/Programs/Python/Python36/Lib/PIL on windows to your projects directory and just import them!
Any library/package you import must have its dependencies and subordinate parts in the same python directory. in linux if you
Python3.x -m pip install <your_library_name_without_braces>
what happens is, it installs on the default python. so first make sure that only 1 python 2.x and 1 python 3.x versions are on your pc.
If you want to successfully install matplotlib
you need these lines,
python -m pip install matplotlib pillow numpy pandas
the last 2 were auxiliary libs, and must have.
what that worked for me:
go to the fodler
C:\Users\{YOUR PC USER NAME}\AppData\Local\Programs\Python\Python37-32\Lib\site-packages
and either delete or change the name of the PIL folder and DONE.
had to do it after running
pip uninstall PIL
as other suggested yielded for me
WARNING: Skipping PIL as it is not installed.
But I am not sure about the consequences of removing that library so I will edit this post if I ever get into a problem because of that.
Now, I actually did some debugging with my brother and found that Pillow (PIL) needed to be initialized. I don't know how to initialize it, so you could probably stick with reinstalling Pillow.
Try import PIL instead of from PIL import image.