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

Importerror_ cannot import name 'pillow_version' from 'pil'

Pillow is a python library for image processing. You can manipulate or save images using it after modifying them. But you may get the error like importerror: cannot import name ‘pillow_version’ from ‘pil’. If you are getting this error then this post is for you. In this entire tutorial, you will know how to solve this cannot import name ‘pillow_version’ from ‘pil’ error.

Why importerror: cannot import name ‘pillow_version’ from ‘pil’ Error occurs?

The root cause of this importerror is that the python interpreter is unable to find the pillow_version function. In the other case may you must be using a different version of the pillow module that doesn’t support the pillow_version.

If you will try to import the pillow_version from PIL I will get the below error.

from PIL import pillow_version

Output

cannot import name pillow_version error
cannot import name pillow_version error

Solution of the cannot import name ‘pillow_version’ from ‘pil’

The solution to this importerror is very simple. There are two best solutions for it.

Solution 1: Use different function

If you want to find the version of the installed pillow then use ” __version__ ” instead of pillow_version. It’s because the newest version of the pillow module doesn’t support this method.

from PIL import __version__
print(__version__)

Output

7.1.2

Solution 2: Downgrade the Pillow module

Another solution is to downgrade the pillow module. The pillow_version is only supported by the Pillow version less than 7.0.0. You can see in the above solution the version of the pillow module is 7.1.2. So you have to first uninstall the existing pillow module and after that install the Pillow version less than 7.

Open your command prompt or terminal and type the below command to install the Pillow.

pip uninstall pillow
pip install "pillow<7"

If you are using anaconda then use the below command.

conda install -c anaconda pillow<7

Now you can use the pillow_version. You will not get the importerror: cannot import name ‘pillow_version’ from ‘pil’ Error.

Conclusion

Pillow is a great library for image processing. If you are getting the error cannot import name ‘pillow_version’ from ‘pil’ then there is two best solutions.

The first solution is to use ” __version__” instead of the pillow_version. The second one is to downgrade the pillow module to less than the 7.00 version.

I hope you have liked this tutorial. If you have any queries then you can contact us for more help.

 

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 Sukesh ( Chief Editor ), a passionate and skilled Python programmer with a deep fascination for data science, NumPy, and Pandas. His journey in the world of coding began as a curious explorer and has evolved into a seasoned data enthusiast.
 
Thank you For sharing.We appreciate your support. Don't Forget to LIKE and FOLLOW our SITE to keep UPDATED with Data Science Learner