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