ImportError: No module named PIL python 2.7.10 - python

I am not able to import PIL on macOS, it works fine on windows with python version 2.7.16.
Any help for python 2.7.10 would be much appreciated.
from PIL import Image
ERROR:-
ImportError: No module named PIL
I am getting this error with python (2.7.10) pip(19.1.1) on macos Mojave (10.14.4)
pip list outputs pillow in the packages version (5.2.0)
pip install pillow
Logs the following:
Requirement already satisfied: pillow in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (5.2.0)
But i am still unable to import the package.
Any workarounds for this?

Related

Unable to import PIL into project

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

Library Pillow - cannot import name '_imaging' from 'PIL' - ERROR [duplicate]

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

ImportError: No module named skimage.io

I have already installed my scikit-image on my following path:
Requirement already satisfied: scikit-image in /usr/local/lib/python3.6/site-packages (0.14.0)
This is what I can get when I type pip install scikit-image on my mac terminal
However, whenever I run the following:
import skimage.io as io
It keeps returning error as below :
ImportError: No module named skimage.io
What would be the cause of this import failure?
The problem of mine caused from the using python3.
Python3 shares different module path from that of python2.

Importing package installed with pip3 causes ImportError

I installed the pillow 3.3.0 package for Python 3.5.2 Mac by using the pip3 install statement in terminal, it successfully downloaded and installed. (I did the same for other pacakges.)
When trying to call import pillow, following warning is displayed:
>>>import pillow
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
from pillow import *
ImportError: No module named 'pillow'
I took following steps:
Those are the packages locally installed:
import pip
installed_packages = pip.get_installed_distributions()
installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
for i in installed_packages])
print(installed_packages_list)
['numpy==1.11.1', 'pillow==3.3.0', 'pip==8.1.2', 'psycopg2==2.6.2', 'setuptools==20.10.1']
When pip3 installing pillow again, following warning shows up:
MyComputer-MBP-2:~ user$ pip3 install Pillow
Requirement already satisfied (use --upgrade to upgrade): Pillow in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Other packages work just fine.
The importable name of the Pillow library is PIL because it is a fork of the original PIL. Just do
from PIL import *
Or even better, only import those names you actually need—see this SO thread.
the package name is PIL
use
from PIL import *

ImportError: No module named Image [duplicate]

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

Categories

Resources