Modulenotfounderror 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?

Eric O. Lebigot's user avatar

asked Jan 14, 2012 at 17:24

Asma Gheisari's user avatar

Asma GheisariAsma Gheisari

5,6649 gold badges29 silver badges51 bronze badges

5

In shell, run:

pip install Pillow

Attention: PIL is deprecated, and pillow is the successor.

sehe's user avatar

sehe

371k47 gold badges450 silver badges628 bronze badges

answered Mar 28, 2014 at 20:49

zhiming wang's user avatar

6

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

answered Jan 14, 2012 at 17:36

Eric O. Lebigot's user avatar

Eric O. LebigotEric O. Lebigot

90.5k48 gold badges217 silver badges260 bronze badges

12

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..

kba's user avatar

kba

1,0979 silver badges20 bronze badges

answered Jul 23, 2013 at 9:24

Damian's user avatar

DamianDamian

2,57823 silver badges19 bronze badges

1

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.

Anshul Goyal's user avatar

Anshul Goyal

72.4k37 gold badges147 silver badges182 bronze badges

answered Feb 25, 2013 at 15:01

Fernando Munoz's user avatar

Fernando MunozFernando Munoz

4,5112 gold badges18 silver badges16 bronze badges

4

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.

answered Nov 17, 2016 at 14:56

grooveplex's user avatar

grooveplexgrooveplex

2,4824 gold badges28 silver badges30 bronze badges

4

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:Python27Scripts

then run below command

pip install image

answered Jan 2, 2018 at 13:18

azdoud's user avatar

azdoudazdoud

1,2199 silver badges17 bronze badges

2

On windows 10 I managed to get there with:

cd "C:Users<your username>AppDataLocalProgramsPythonPython37-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

answered Aug 20, 2019 at 20:11

andrew pate's user avatar

andrew pateandrew pate

3,78734 silver badges26 bronze badges

1

I used:

pip install Pillow 

and pip installed PIL in Libsite-packages. When I moved PIL to Lib everything worked fine. I’m on Windows 10.

answered Aug 5, 2019 at 0:45

cromastro's user avatar

cromastrocromastro

1611 silver badge4 bronze badges

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 

answered Mar 27, 2021 at 7:33

Shantanu Bombatkar's user avatar

1

On windows, try checking the path to the location of the PIL library. On my system, I noticed the path was

Python26Libsite-packagespil instead of Python26Libsite-packagesPIL  

after renaming the pil folder to PIL, I was able to load the PIL module.

Robert's user avatar

Robert

5,27843 gold badges65 silver badges115 bronze badges

answered Apr 4, 2013 at 11:08

Komla's user avatar

KomlaKomla

911 silver badge1 bronze badge

1

if you use anaconda:

conda install pillow

answered Jan 10, 2018 at 23:02

conor's user avatar

conorconor

1,1211 gold badge14 silver badges20 bronze badges

2

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

answered Dec 9, 2021 at 18:25

Srinivas Ramakrishna's user avatar

2

I had the same issue on windows 10 and this worked for me:

pip install Pillow

answered Mar 7, 2022 at 8:51

Cyebukayire's user avatar

CyebukayireCyebukayire

7677 silver badges14 bronze badges

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

answered May 10, 2017 at 8:43

Dipanshu Sehjal's user avatar

instead of PIL use Pillow it works

easy_install Pillow

or

pip install Pillow

answered Apr 13, 2018 at 5:21

saigopi.me's user avatar

saigopi.mesaigopi.me

13.7k2 gold badges80 silver badges54 bronze badges

pip(3) uninstall Pillow
pip(3) uninstall PIL
pip(3) install Pillow

answered Oct 15, 2020 at 16:34

Newt's user avatar

NewtNewt

7678 silver badges14 bronze badges

This worked for me on Ubuntu 20.04:

pip install image

And in script:

import image

answered Sep 24, 2022 at 13:33

MD. Mohiuddin Ahmed's user avatar

use pil instead of PIL

from pil import Image

answered Sep 5, 2020 at 13:58

Newt's user avatar

NewtNewt

7678 silver badges14 bronze badges

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.

answered Jul 10, 2018 at 16:06

Geoff Perrin's user avatar

Geoff PerrinGeoff Perrin

4341 gold badge6 silver badges14 bronze badges

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

answered Dec 23, 2018 at 23:24

Ori Barmatz's user avatar

I used :

from pil import Image

instead of

from PIL import Image

and it worked for me fine

wish you bests

answered Jul 20, 2020 at 10:12

Heydar's user avatar

HeydarHeydar

1371 silver badge8 bronze badges

I found an easier solution. Use a virtual environment.

pip install Pillow
from PIL import Image

This works for me on a macOS

answered Oct 31, 2021 at 21:14

Thesonter's user avatar

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.

answered May 25, 2015 at 16:47

Prateek Jain's user avatar

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.

Thomasleveil's user avatar

Thomasleveil

93.6k14 gold badges119 silver badges112 bronze badges

answered Jan 9, 2016 at 15:20

Johan's user avatar

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

answered Sep 22, 2020 at 23:46

Jortega's user avatar

JortegaJortega

3,5361 gold badge18 silver badges21 bronze badges

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!

answered Oct 28, 2020 at 18:33

Goob-The-Noob's user avatar

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

answered Nov 22, 2021 at 9:35

Mohamed Berrimi's user avatar

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

answered Jan 14, 2012 at 17:35

Crankyadmin's user avatar

2

  • #1

Здравствуйте! Сегодня столкнулся с проблемой — выбрасывает ошибку

Traceback (most recent call last):
File «C:UserskirilAppDataRoamingMicrosoftWindowsStart MenuProgramsPython 3.7питонецтестытест.py», line 1, in <module>
from PIL import Image, ImageFilter
ModuleNotFoundError: No module named ‘PIL’

Пытался удалять, скачивать pillow… Прочитал множество статей и вопросов на форумах, убив кучу времени. В итоге — не нашел ничего конкретно то, что мне нужно. Поэтому обращаюсь к вам.

Код:

Python:

from PIL import Image

img = Image.open('backgraund.png')
watermark = Image.open('text.png')

img.paste(watermark, (250, 250),  watermark)
img.save("img_with_watermark.png")


0

  • #2

А вы случайно не через PyCharm открываете?


0

  • #3

А вы случайно не через PyCharm открываете?

Нет


0

  • #4

ModuleNotFoundError: No module named ‘PIL’

В ошибке написано что модуль не установлен.
Возможно вы запускаете скрипт в виртуальном окружении, в котором не установлен модуль pillow (можно проверить с помощью команды pip list) или у вас установлено несколько версий питона и для той версии с помощью которой вы запускаете скрипт модуль pillow не установлен.


0

  • #5

В ошибке написано что модуль не установлен.
Возможно вы запускаете скрипт в виртуальном окружении, в котором не установлен модуль pillow (можно проверить с помощью команды pip list) или у вас установлено несколько версий питона и для той версии с помощью которой вы запускаете скрипт модуль pillow не установлен.

У меня установлено только питон 3.7, через pip list проверял и не однократно


0

  • #6

Может проблемы с путями.
Выполните в консоли команды pip -V (покажет версию pip, путь к папке с модулями и версию питона), а потом python -V чтобы убедиться что pip устанавливает пакеты для правильной версии питона.
Также можно выполнить скрипт:

Python:

import sys

print(sys.executable)

он покажет путь к файлу интерпретатора, сравните его с путем из команды pip -V.
Проверьте пути в PATH.


0

  • #7

Может проблемы с путями.
Выполните в консоли команды pip -V (покажет версию pip, путь к папке с модулями и версию питона), а потом python -V чтобы убедиться что pip устанавливает пакеты для правильной версии питона.
Также можно выполнить скрипт:

Python:

import sys

print(sys.executable)

он покажет путь к файлу интерпретатора, сравните его с путем из команды pip -V.
Проверьте пути в PATH.

Проверил, все сходится. Но все по прежнему так и не работает…


0

  • #8

Еще можно выполнить такой скрипт и проверить правильный ли там путь к установленным пакета (...libsite-packages):

Python:

import sys

print(sys.path)  # покажет все пути питона в PATH

If you use the Python Imaging Library (PIL) in your code, you might encounter this error:

ModuleNotFoundError: No module named 'PIL'

This error occurs when you try to import the PIL module without installing the Pillow package.

If you already have the Pillow package, then you may have multiple versions of Python installed on your computer, and Python is looking at the wrong folder for the package.

This article shows examples that cause the error and how to fix it.

1. Install the Pillow library

The PIL package has been forked to the Pillow package, so to import PIL in your code, you need to install Pillow.

First, you need to uninstall PIL because Pillow and PIL cannot co-exist in the same environment:

pip uninstall PIL

# Install pillow next:
pip install pillow --force-reinstall --no-cache

# Or with pip3:
pip3 install pillow --force-reinstall --no-cache

# If you don't have pip in PATH:
python -m pip install --upgrade pillow

python3 -m pip install --upgrade pillow

# If you use Anaconda or conda
conda install -c conda-forge pillow

# Installing from Jupyter Notebook
!pip install pillow

Once you installed Pillow, you can import PIL with the following code:

from PIL import Image

img = Image.open("test.png")

Please note that you can’t use import PIL or import Image. The latest Pillow version requires you to state the import exactly as from PIL import Image.

If you use the module like this:

import PIL

img = PIL.Image.open("test.png")

You’ll get the following error:

Traceback (most recent call last):
  File "main.py", line 3, in <module>
    img = PIL.Image.open("test.png")
          ^^^^^^^^^
AttributeError: module 'PIL' has no attribute 'Image'

You also need to replace import _imaging as shown below:

# from:
import _imaging

# to:
from PIL.Image import core as _imaging

Now that you have Pillow installed, you should be able to use PIL without any errors.

If that doesn’t work, then you might have multiple Python versions installed on your computer.

2. Check if you have multiple Python versions installed

If you have multiple versions of Python installed on your system, you need to make sure that you are using the specific version where the pillow module is installed.

You can test this by running the which -a python and which -a python3 commands from the terminal:

$ which -a python
/usr/local/bin/python

$ which -a python3
/usr/local/bin/python3
/usr/bin/python3

In the example above, there are multiple versions of Python installed on the system:

  • Python 2 installed on /usr/local/bin/python
  • Python 3 installed on /usr/local/bin/python3 and /usr/bin/python3

Each Python distribution is bundled with a specific pip version. If you want to install a module for Python 2, use pip. Otherwise, use pip3 for Python 3.

The problem arise when you install pillow for Python 2 but runs the code using Python 3, or vice versa:

# Install Pillow for Python 2
$ pip install pillow

# Run the code with Python 3
$ python3 main.py 

# Or Install Pillow for Python 3
$ pip3 install pillow

# Run the code with Python 2
$ python main.py 

If you install Pillow for Python 2, then you need to run the code using Python 2 as well:

$ pip install pillow
$ python main.py 

Having multiple Python versions can be confusing, so you need to carefully inspect how many Python versions you have on your computer.

3. No module named PIL in Visual Studio Code (VSCode)

If you use VSCode integrated terminal to run your code, you might get this error even when Pillow is already installed.

This means the Python and pip versions used by VSCode differ from the one where you install Pillow.

You can check this by running the following code:

import sys
print(sys.executable)

The print output will show you the absolute path to the Python used by VSCode. For example:

Copy the path shown in the terminal and add -m pip install pillow as follows:

/path/to/python3 -m pip install pillow

This will install pillow for the Python interpreter used by VSCode. Once finished, try running your code again. It should work this time.

Conclusion

Most likely, you see the No module named PIL error because you didn’t install the pillow package from pip, or you installed the package on a different version of Python.

The steps shown in this article should help you fix this error.

I hope this article is helpful. Happy coding! 👋

If you get the error ModuleNotFoundError: No module named ‘PIL’ in Python and don’t know what to do. The cause of the error is that you have not installed the Pillow module so I have a few suggestions for installing the Pillow module for you. Read the article below.

What causes the ModuleNotFoundError: No module named ‘PIL’ error?

The ModuleNotFoundError: No module named ‘PIL’ error happens because you have not installed the ‘Pillow’ module to be able to use it or you installed the wrong environment. I will do the installation in a virtual environment.

How to solve this error?

Install library ‘PIL’ .

Install the ‘Pillow’ module. You can use Python pip. But note that you need to specify the exact version of Python you are using.

Example:

If you don’t have pip installed here is the solution for you in Python 3:

python -m pip install Pillow

If you use Python 3, use the pip3 statement as follows:

pip3 install Pillow

Install ‘Pillow’ on operating systems.

I would install ‘Pillow’ according to your operating system.

Install ‘Pillow’ on Windows using pip

Before installing ‘Pillow’, you need to create a virtual environment. Using a virtual environment helps you avoid incompatibilities between packages and break the system if you install incompatible libraries with your operating system.

You can activate the virtual environment with the following command:

venvScriptsActivate.ps1

Then you can install the ‘Pillow’ module with the following command:

python3 -m pip install Pillow

If you do not have pip installed, use the following command:

python3 -m pip install Pillow

Install ‘Pillow’ on Mac using pip

Make sure you have installed Python and pip. Just like on Windows operating systems, you also need a virtual environment. Just like on Windows operating systems, you also need your virtual environment. You can activate the virtual environment with the following command:

source venv/bin/activate

Install ‘Pillow’ in the command prompt environment:

python3 -m pip install Pillow

Install module ‘Pillow’ by Anaconda

Anaconda is the most popular open-source Data Science platform available on Python. Install Anaconda first, create a virtual environment, and install ‘Pillow’.

To create an anaconda environment:

conda create -n pil-env python=3.6

Finally, install ‘Pillow’ with the command:

conda install -c anaconda pillow

Import PIL module.

After you have installed the Pillow module, you can use it. Pillow is a fork from the PIL library with image processing functionality.

Example:

from PIL import Image

# Open and load images in your folder.
imageInfor = Image.open('the_cat.jpg')

# Parameters about the image by accessing its attributes.
print(imageInfor.format, imageInfor.size, imageInfor.mode)

Output:

JPEG (1000, 800) RGB

Summary

That’s how I figured out how to solve the error ModuleNotFoundError: No module named ‘PIL’ in Python. Hopefully, the article can help you. If you have any ideas or better ways, please comment below.

Jason Wilson

My name is Jason Wilson, you can call me Jason. My major is information technology, and I am proficient in C++, Python, and Java. I hope my writings are useful to you while you study programming languages.


Name of the university: HHAU
Major: IT
Programming Languages: C++, Python, Java

Python Image Library or PIL is an image processing module developed for Python. It provides image processing tools that help in creating, editing, and exporting image files. However, the PIL project was abandoned in 2011. To continue providing support for the latest Python versions, the Pillow module forked the PIL module. The Pillow module eventually replaced PIL and became the go-to image processing library for Python.

The Python interpreter may not detect specific modules when imported. Therefore, upon execution, Python will return the ModuleNotFoundError: No module named 'pil' exception and exits the program.

For example, let’s say we’re importing a package called “run”. We would do so by using the import statement followed by the package name; run. Since there is no module called “run”, this error is shown.

No module named "run"

Causes & Solutions For No Module Named Pil

There are multiple reasons why this exception may be raised. Let’s look at the following instances.

Package Not Installed Properly

This is probably the most typical reason for this exception. Some libraries may not be part of the Python Standard Library. Therefore they require additional installation steps before we can use them.

In specific IDEs (e.g., spyder), make sure your module are all installed in a single folder. PIP installer may install your package in one place, whereas the IDE expects the module in another directory. Make sure to save all external dependencies in one place.

It is vital to ensure that the correct installation commands for provided to install Pillow.

Windows Installation
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow

macOS Installation
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow

Linux Installation
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow

Multiple Python Versions Installed

Installing multiple versions of Python can result in multiple library folders for each version. Therefore, ensure the library is present in the correct version of Python.

Here’s how we can find the installation location for your version of Python

Open up the Python command terminal

Python application 3.10

Type the following lines of commands

import os
import sys
os.path.dirname(sys.executable)

Output

Python location

So the location would be: ‘C:UsersAdminAppDataLocalProgramsPythonPython310’

Incorrect Package Name

Certain packages have import statements that are different from their actual names. One notable example is a web scraping library called BeautifulSoup. The common user may attempt to import the module by calling import BeautifulSoup.

However, this is incorrect. You must go through the documents of each module and figure out the correct import command to avoid confusion. Furthermore, the correct implementation for the said example would be: import bs4

Importing Files

Another reason for the error to arise is importing Python files incorrectly. For example, let’s assume we’re importing the file “program.py”. To import this, we run “import program” excluding the .py extension. It is also essential to ensure that the file is present in the working directory. If failed to do so, the following error will appear:

No module named program

Another rule to remember is that do not use names of pre-existing packages as your Python file name i.e pil.py. If done otherwise, the Python interpreter will consider pandas as your Python file rather than the pil package itself. This will cause problems when working with your file and the package.

[Fixed] SSL module in Python is Not Available

Python No Module Named Pil Visual Studio Code

Users tend to face an issue with the module in VSCode. Upon importing, the program may run perfectly, but under the problems tab, this may appear:

import PIL could not be resolved from source. Pylance(reportmissingmodulesource) 

This error is caused due to the fact that VS Code isn’t running the same Python interpreter between the two or more versions. Modules are installed on one of the Python versions you have. Therefore, we must determine the path to the Python executable. Refer to the following command

import sys
print(sys.executable)

This will show us the location in which Python is installed. If you run the same command on VS Code, it will show a different location. In order to have the versions in the same location, we must install the Python interpreter that is being used by VS Code. Type this in your terminal

/path/to/python/used/by/vs/code/python -m pip install pillow

No Module Named pil.imagetk

For Versions Below Python 3

This is due to the fact that Python is installed in a different location than the standard one. This can be fixed by re-installing Python to the standard location or by appending the location to sys.path.

For Versions Above Python 3

Python 3 and above imagetk comes under the Pillow module. Therefore, in order to import, run the following command.

PIL is a deprecated project, and no further support is provided. However, the Pillow project forked PIL to provide support for the latest Python versions. For macOS machines, the following command needs to be entered.

sudo pip install pillow

In some instances, the following error may appear.

ImportError: No module named PIL

An easy solution to this problem is to make sure PIP is upgraded to the latest versions. PIP makes sure all your packages are unzipped and loaded into Python, ready to use. Therefore, it is vital to upgrade PIP in order to install the latest versions of modules. You can upgrade PIP using the following command in macOS

sudo pip install  --upgrade pip

No Module Named PIL (Ubuntu)

In some versions of PIL in Ubuntu, it may come under the name imaging. Therefore in order to install Pillow in Ubuntu, run the following command.

sudo apt-get install python-imaging

No Module Named PIL (Raspberry Pi)

Upon installing the module on your Pi 0, you may be presented with the following error

sudo apt-get install python-pillow python-pil
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'python-pil' instead of 'python-pillow'
python-pil is already the newest version (5.4.1-2+deb10u2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Despite the successful installation, you may be presented with No Module Named Pil error upon running your Python file.

This may be due to the fact that the version of PIL and Python do not match. Make sure your Pi has the correct version of Python installed, and it makes sure the PIL installation matches your Python version.

Upon installation, the .exiftags function may not work. This may be due to the fact that other versions of the same module may cause the file to be deleted or overwritten.

Deleting all module versions and only saving the latest one can fix this issue.

FAQs

The module name is Pillow, but we use pil to import it. Why?

Support for Python Image Library has been discontinued. Therefore, for the module to work on newer Python versions, the Pillow project forked the existing PIL project. All functionalities from PIL are present in Pillow as well.

How to add pillow in requirements.txt?

Add RUN apk add zlib-dev jpeg-dev gcc musl-dev within your docker file and add Pillow within the requirements.txt file

What is the use of the Pillow module in Python?

Pillow provides image processing capabilities for Python. It has multiple file format support and powerful image processing abilities.

Conclusion

We’ve gone through various causes for Python No Module Named Pil exception. Make sure to keep these reasons in mind, as most “No Module Named” errors have similar reasons.

Trending Python Articles

  • [Fixed] SSL module in Python is Not Available

    [Fixed] SSL module in Python is Not Available

    May 30, 2023

  • Mastering Python Translate: A Beginner’s Guide

    Mastering Python Translate: A Beginner’s Guide

    by Namrata GulatiMay 30, 2023

  • Efficiently Organize Your Data with Python Trie

    Efficiently Organize Your Data with Python Trie

    by Namrata GulatiMay 2, 2023

  • [Fixed] modulenotfounderror: no module named ‘_bz2

    [Fixed] modulenotfounderror: no module named ‘_bz2

    by Namrata GulatiMay 2, 2023

Понравилась статья? Поделить с друзьями:
  • Module datetime has no attribute now ошибка
  • Modular voice chat ошибка переподключение
  • Modr клуб романтики ошибка
  • Modifier is disabled skipping apply blender ошибка
  • Modern warfare код ошибки