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.

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

Other Must Read –

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

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.

 
Thank you For sharing.We appreciate your support. Don't Forget to LIKE and FOLLOW our SITE to keep UPDATED with Data Science Learner