How to install PIL in Pycharm with Python 3? - python

I can't get PIL to work on pycharm. It should work after installing Pillow / Pillow-PIL libraries but it doesn't.
What am I missing?

This question is apparently the same than this other issue:
How do I install PIL/Pillow for Python 3.6?
pip install pillow should be the answer
Else, you can try Anaconda, it is already installed by default.
But this does not explain your issue.

Related

I installed Pillow but i get "ModuleNotFoundError: No module named 'PIL'"

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 ;)

Cannot download Pillow in Django VSCode project (Windows)

I'm going through Django 2.2 course with Windows / VSCode / Anaconda setup. I've tried to use both Python 3.6 and 3.7 interpreters and tried to download Pillow with commands such as:
pip install Pillow
python -m pip install pillow
pip install Pillow==5.0.0
I've tried to execute this both in is Anaconda Shell Prompt and cmd. Simply put, I get error of missing Pillow package whatever I do. When I try to execute "conda install" it says the the requirement is already satisfied, but it still doesn't recognize the package.
See attached pictures about errors.
Error1
Error2
Pillow 5.0.0 doesn't support Python 3.7. So, you have to install Pillow 5.2 - 5.4 or later versions of Pillow for Python 3.7.
You can check it from pillow's documentation here: pillow documentation
Also, be careful of different versions of python installed on your computer. check it and be sure which version is using.

Python - can not install some packages in latest version

I have installed 3.6.1 version of python interpreter. I have a project that need to use "PIL" library so I try to install it but it gives me error, "Error occurred when installing package 'PIL'". I search it out why it's happening and I think it can only be installed on lower version of interpreter 2.7 or something lower. Now how can I install PIL in 3.6.1 version of interpreter? Should I downgrade my interpreter instead? But if I do, can it cause some other packages to be unable to install for it is only for 3.X version. Thanks in advance.
Install Pillow, the packaged and maintained fork of PIL, using:
pip install pillow
download pillow based on your version. from python unofficial library ..
search pillow choose your python version and distribution from it... once you download,
move onto download path or
pip install ~/Downloads/Pillow‑4.2.1‑cp36‑cp36m‑win_amd64.whl

PIL: DLL load failed: specified procedure could not be found

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

ImportError: No module named PIL

I use this command in the shell to install PIL:
easy_install PIL
then I run python and type this: import PIL. But I get this error:
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named PIL
I've never had such problem, what do you think?
In shell, run:
pip install Pillow
Attention: PIL is deprecated, and pillow is the successor.
On some installs of PIL, you must do
import Image
instead of import PIL (PIL is in fact not always imported this way). Since import Image works for you, this means that you have in fact installed PIL.
Having a different name for the library and the Python module is unusual, but this is what was chosen for (some versions of) PIL.
You can get more information about how to use this module from the official tutorial.
PS: In fact, on some installs, import PIL does work, which adds to the confusion. This is confirmed by an example from the documentation, as #JanneKarila found out, and also by some more recent versions of the MacPorts PIL package (1.1.7).
On a different note, I can highly recommend the use of Pillow which is backwards compatible with PIL and is better maintained/will work on newer systems.
When that is installed you can do
import PIL
or
from PIL import Image
etc..
At first install Pillow with
pip install Pillow
or as follows
c:\Python35>python -m pip install Pillow
Then in python code you may call
from PIL import Image
"Pillow is a fork of PIL, the Python Imaging Library, which is no longer maintained. However, to maintain backwards compatibility, the old module name is used." From pillow installed, but "no module named pillow" - python2.7 - Windows 7 - python -m install pillow
This worked for me on Ubuntu 16.04:
sudo apt-get install python-imaging
I found this on Wikibooks after searching for about half an hour.
Sometimes I get this type of error running a Unitest in python. The solution is to uninstall and install the same package on your virtual environment.
Using this commands:
pip uninstall PIL
and
pip install PIL
If for any reason you get an error, add sudo at the beginning of the command and after hitting enter type your password.
you have to install Image and pillow with your python package.
type
python -m pip install image
or run command prompt (in windows), then navigate to the scripts folder
cd C:\Python27\Scripts
then run below command
pip install image
On windows 10 I managed to get there with:
cd "C:\Users\<your username>\AppData\Local\Programs\Python\Python37-32"
python -m pip install --upgrade pip <-- upgrading from 10.something to 19.2.2.
pip3 uninstall pillow
pip3 uninstall PIL
pip3 install image
after which in python (python 3.7 in my case) this works fine...
import PIL
from PIL import image
I used:
pip install Pillow
and pip installed PIL in Lib\site-packages. When I moved PIL to Lib everything worked fine. I'm on Windows 10.
Install Specific Version:
pip install Pillow
Upgrade Pillow
sudo pip3 install --upgrade Pillow
Getting Dependency Error in Window 10
Use code: easy_install instead of pip install
easy_install Pillow
Upgrade using easy install
sudo easy_install --upgrade Pillow
On OSX System to install Module:
Use code: brew install instead of pip install
brew install Pillow
Without Using Pip :
sudo apt-get install -y Pillow
On CentOS7 or Linux Fedora:
yum -y install Pillow
Or on Fedora try
sudo dnf install Pillow
Command if Homebrew screws up your path on macOS:
python -m pip install Pillow
For Python3 MacOs Homebrew screws
python3 -m pip install Pillow
Verify module from list MacOs
pip freeze | grep Pillow
For Execute on Anaconda as your python package manager
conda install -c anaconda Pillow
On windows, try checking the path to the location of the PIL library. On my system, I noticed the path was
\Python26\Lib\site-packages\pil instead of \Python26\Lib\site-packages\PIL
after renaming the pil folder to PIL, I was able to load the PIL module.
if you use anaconda:
conda install pillow
You will need to install Image and pillow with your python package.
Rest assured, the command line will take care of everything for you.
Hit
python -m pip install image
instead of PIL use Pillow it works
easy_install Pillow
or
pip install Pillow
The cleanest way to resolve this issue is by following below steps.
Step 1: Uninstall the PIL package.
pip uninstall PIL
Step 2: Install the Pillow using pip as shown below on windows operating systems. For other environments checkout the article No module named PIL
On Windows
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow
Step 3: The most crucial class in the Python Imaging Library is the Image class, and you can import this as shown below.
from PIL import Image
im = Image.open("myimage.jpg")
If successful, this function returns an Image object. You can now use instance attributes to examine the file contents:
print(im.format, im.size, im.mode)
#Output: PPM (512, 512) RGB
I had the same issue on windows 10 and this worked for me:
pip install Pillow
pip(3) uninstall Pillow
pip(3) uninstall PIL
pip(3) install Pillow
This worked for me on Ubuntu 20.04:
pip install image
And in script:
import image
use pil instead of PIL
from pil import Image
On Windows, you need to download it and install the .exe
https://pypi.python.org/pypi/Pillow/2.7.0
I used conda-forge to install pillow version 5, and that seemed to work for me:
conda install --channel conda-forge pillow=5
the normal conda install pillow did NOT work for me.
I had the same problem and i fixed it by checking what version pip (pip3 --version) is, then realizing I'm typing python<uncorrect version> filename.py instead of python<correct version> filename.py
I used :
from pil import Image
instead of
from PIL import Image
and it worked for me fine
wish you bests
I had the same issue while importing PIL and further importing the ImageTk and Image modules. I also tried installing PIL directly through pip. but not success could be achieved. As in between it has been suggested that PIL has been deprectaed, thus, tried to install pillow through pip only. pillow was successfully installed, further, the PIL package was made under the path : python27/Lib/site-packages/.
Now both Image and ImageTk could be imported.
I recently installed Leap. I Tried openshot and it didn't start. So came here and found a suggestion to start from the Terminal to see if there were any error.
The error I had was error missing mlt. So I installed the python-mlt module from Yast and imported it, tried to start but next openshot said missing pil.
I Followed the Pillow suggestion to install because Yast couldn't find any pil and imported pil. That went ok but did not start and showed Error missing goocanvas.
The I installed goocanvas with Yast, imported it in python, and Openshot fired up !!
With a lot of errors in the terminal like missing Vimeoclient and lots of attributeerrors. Well, will see if it is of any influence working with it.
Python 3.8 on Windows 10. A combination of the answers worked for me. See below for a standalone working example. The commented out lines should be executed in the command line.
import requests
import matplotlib.pyplot as plt
# pip uninstall pillow
# pip uninstall PIL
# pip install image
from PIL import Image
url = "https://images.homedepot-static.com/productImages/007164ea-d47e-4f66-8d8c-fd9f621984a2/svn/architectural-mailboxes-house-letters-numbers-3585b-5-64_1000.jpg"
response = requests.get(url, stream=True)
img = Image.open(response.raw)
plt.imshow(img)
plt.show()
I had the same issue and tried many of the solutions listed above.
I then remembered that I have multiple versions of Python installed AND I use the PyCharm IDE (which is where I was getting this error message), so the solution in my case was:
In PyCharm:
go to File>Settings>Project>Python Interpreter
click "+" (install)
locate Pillow from the list and install it
Hope this helps anyone who may be in a similar situation!
I found an easier solution. Use a virtual environment.
pip install Pillow
from PIL import Image
This works for me on a macOS
According to the official websiteInstall Pillow, you may want to try this:
go to Terminal and run:
python3 -m pip install --upgrade pip
Then Run on
source ~/.bash_profile
You are probably missing the python headers to build pil. If you're using ubuntu or the likes it'll be something like
apt-get install python-dev

Categories