Modulenotfounderror: no module named pil ( Solved )

Modulenotfounderror no module named pil ( Solved )

Modulenotfounderror: no module named pil error occurs if the pillow package is not installed or not properly configured. The best way to resolve this error is to reinstall the pillow module again. In some of the cases, the same error occurs because of importing the PIL module in the place of the image module.  In this article, we will see the different easiest ways to install pillow modules. Also, we will address the import issue. So let’s start.

What is the Pillow (pil ) Python module?

The pillow module allows you to manipulate and save images in different file formats like JPEG, PNG, BMP, GIF, TIFF, and others. You can perform many operations like cropping, resizing, rotating, color conversions, and more. You can also do image processing operations like filtering and enhancing. In addition, it allows you to add watermarks or captions to the images.

Modulenotfounderror: no module named pil ( Solution )-

The best and easiest way to install any python package is using any package manager either pip, conda, or some other like  easy_install. Here in a single line command we can install any python package.

pillow package
pillow package

Solution 1: pip for pillow installation –

Use this command to install the pillow with the pip package manager.

pip install Pillow

We can install any version of the pillow by just adding the version in the pillow command. For version, detail refers to the release details of pillow.

pip install Pillow==9.2.0

For admin rights please add sudo keyword in Linux similar OS and In windows, launch the cmd in Admin mode. If you are getting permission issues.
If pip is not properly configured then run the below command.

python -m pip install Pillow

Solution 2: conda for pillow installation –

conda comes with Anaconda distribution.

conda install -c conda-forge pillow

Here we can change the mirrors just like in the above command we are using conda-forge mirror we can use the below mirror as well.

conda pillow installation modulenotfounderror
conda pillow installation modulenotfounderror

Solution 3: Source for pillow installation –

Here we will build pillow packages locally. For this, we need to download the source code for the pillow package and then run the

python install setup.py

Notes :

We need to take care of few import statements like –

1. In the place of

import Image

use

from PIL import Image

2. In the place of

import _imaging

use

from PIL.Image import core as _imaging

 

Similar to Modulenotfounderror if you are experiencing importerror with PIL Read the below article.

Importerror no module named PIL Error Fix : In Steps

Importerror: cannot import name ‘pillow_version’ from ‘pil’ ( Solved )

Other Must Read –

opencv is more over related libraries like pil. Hence you want to explore more the installation and operations of opencv, please read the below article.

importerror: cannot import name registermattype from cv2.cv2 (Fix It)

Importerror No Module Named cv2 : How to Fix ?

OpenCV cv2 circle method Implementation with steps

Thanks
Data Science Learner Team

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

Meet Abhishek ( Chief Editor) , a data scientist with major expertise in NLP and Text Analytics. He has worked on various projects involving text data and have been able to achieve great results. He is currently manages Datasciencelearner.com, where he and his team share knowledge and help others learn more about data science.
 
Thank you For sharing.We appreciate your support. Don't Forget to LIKE and FOLLOW our SITE to keep UPDATED with Data Science Learner