This question already has answers here:
Cannot import name '_imaging' from 'PIL'
(3 answers)
Closed 2 years ago.
I am having problems with the module PIL/Pillow. I installed it with pip install pillow and everything worked fine. But when I start a program that needs this module, it recognizes it, but shows the following error message: ImportError: cannot import name '_imaging' from 'PIL' (see picture).
from PIL import Image
[Click to see the Pic with the Error]
See also these pictures:
Script-Code
Image.py
It seems that many have this problem, but I have not found a solution to my problem anywhere. Neither in the forum nor in Google. How do I fix this?
Python version: 3.8.2
Pillow version: 8.1.0
This can happen because you have PIL and Pillow installed. Pillow is a fork of PIL and is the maintained library. It is recommended not to use PIL because it has become outdated. Here are the steps to fix the problem:
pip uninstall PIL
pip uninstall pillow
then:
pip install pillow
If this doesn't solve the problem, go into your python site-packages or dist-packages and remove any files or folders related to PIL or pillow, then:
pip install pillow
Related
This question already has answers here:
Python program works only from pycharm, not somewhere else
(3 answers)
Closed 10 months ago.
To use the pillow module I wrote down the command:
pip install pillow
And in the file to use I wrote:
from PIL import Image
But I get the error:
ModuleNotFoundError: No module named 'PIL'
what can I do?
Install pillow by writing pip install Pillow in your terminal. (P in Pillow is capitalised )
Then you can call the image library using: from PIL import Image (PIL in all capital and Image is capitalised)
The PIL module should be installed because when I run the pip install pillow I get this message: Requirement already satisfied: pillow in [my installation route]. But, when I try to import this into a file, I get this error:
ModuleNotFoundError: No module named 'Pillow'
What am I doing wrong?
this has worked for me if your using vscode try install by typing py -m pip install pillow
from PIL import ImageTk,Image
Pillow is a fork of PIL, and the import is carried over.
import PIL
Should do the trick. The documentation has additional details:
https://pillow.readthedocs.io/en/stable/installation.html
This question already has an answer here:
Pillow installed, but getting "no module named pillow" when importing
(1 answer)
Closed 6 years ago.
I used sudo pip3 to install Pillow in Python 3.5 (without sudo it will prompt PermissonError) and it said
Requirement already satisfied (use --upgrade to upgrade): Pillow in /usr/local/lib/python3.5/dist-packages
But when I tried to use it in the Program. It shows:
File "./level7.py", line 4, in <module>
from Pillow import Image
ImportError: No module named 'Pillow'
My first few lines in my program are:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
from Pillow import Image
Besides, I found that in /home/-uname/.local/lib file, there is a Python2.7 file, but no Python3.5.
What's the relation between /usr/local and /home/-uname/.local? And how to fix this problem?
Based off of the documentation for Pillow, you are actually supposed to import it as:
from PIL import Image
I've used Pillow in the past on OSX without problems, however I now get the following error.
File "/Library/Python/2.7/site-packages/PIL/Image.py", line 61, in <module>
from PIL import _imaging as core
ImportError: dlopen(/Library/Python/2.7/site-packages/PIL/_imaging.so, 2): Library not loaded: /usr/local/lib/libjpeg.8.dylib
Referenced from: /Library/Python/2.7/site-packages/PIL/_imaging.so
Reason: image not found
I've seen this question which appears to be a similar problem but I don't think I installed Pillow with brew.
I've also tried the solution from this question but the command
pip install PIL --allow-external PIL --allow-unverified PIL
dosent seem to work and I get an error (no such option: --allow-unverified)
Lastly, I've tried to recreate the symbolic link to libjpeg.8.dylib but that also did not make any difference.
Would anyone know how to fix this error? Do I need to do something to relink _image.so aswell as libjpeg?
Python PIL was deprecated eons ago and you should not attempt to use it anymore.
What you want is python[23] -m pip install Pillow
PS. Using pip command will be deprecated soon because of confusions regarding python interpreters, instead of calling pip ... everyone should use only python -m pip ... which assures that is calling the right interpreter.
This question already has answers here:
The problem with installing PIL using virtualenv or buildout
(4 answers)
Closed 6 years ago.
I have also tried
from PIL import Image
but it gives me ImportError: No module named PIL.
I have installed PIL successfully using
pip install pil
and I've also installed xcode command line tools. Nothing seem to work.
Details:
Mac OS X 10.9
Python 2.7.6
python is /Library/Frameworks/Python.framework/Versions/2.7/bin/python
python is /usr/bin/python
python is /usr/local/bin/python
Name: PIL
Version: 1.1.7
Location: /usr/local/lib/python2.7/site-packages/PIL
The PIL distribution is mispackaged for egg installation.
Install Pillow instead, the friendly PIL fork.
On a system with both Python 2 and 3 installed and with pip2-installed Pillow failing to provide Image, it is possible to install PIL for Python 2 in a way that will solve ImportError: No module named Image:
easy_install-2.7 --user PIL
or
sudo easy_install-2.7 PIL