ModuleNotFoundError: No module named 'PIL' error [duplicate] - python

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)

Related

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

How to fix: ModuleNotFoundError: No module named 'scipy' import error [duplicate]

This question already has answers here:
ImportError: No module named scipy
(17 answers)
Closed 3 years ago.
I am setting up a speech recognition software using mozilla and want to use the pre-trained model.
This is for macosx, I have already installed pip and the related scipy file however my system cant seem to pull the scipy module when I run my python script. Could it be that this is installed in another directory from the virtual env itself?
Terminal
(deepspeech-venv) Chabanis-MacBook-Pro:deepspeech chabani$ pip3 list
Package Version
---------- -------
deepspeech 0.5.1
numpy 1.17.0
pip 19.2.1
scipy 1.3.1
setuptools 41.0.1
wheel 0.33.4
Python
import scipy.io.wavfile as wav // this is the issue here
Terminal - deepspeech path
(deepspeech-venv) Chabanis-MacBook-Pro:deepspeech chabani$ which deepspeech
/Users/chabani/tmp/deepspeech-venv/bin/deepspeech
=== RESTART: /Users/chabani/tmp/deepspeech-venv/lib/python3.7/activate.py ===
Traceback (most recent call last):
File "/Users/chabani/tmp/deepspeech-venv/lib/python3.7/activate.py", line 7, in <module>
import scipy.io.wavfile as wav
ModuleNotFoundError: No module named 'scipy'
try to run this command:
pip3 install scipy

ImportError: No module named cv2 when executing Python script [duplicate]

This question already has answers here:
Cannot find module cv2 when using OpenCV
(24 answers)
Closed 5 years ago.
I need to execute a Python application, but I am getting this error:
Traceback (most recent call last): File "dataset.py", line 8, in import cv2 ImportError: No module named cv2
I have followed the face detection concept in 96 boards, but I keep getting above error message, when I run the script like this:
sudo python dataset.py
Have you installed openCV?
sudo apt-get install python-opencv
If you want install it with pip:
pip install opencv

Pillow has already installed, but appears ImportError - Python3.5 Ubuntu [duplicate]

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

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