I know PIL is deprecated, so I installed Pillow instead, and for backward compatibility reason, Pillow is still using PIL as its module name. Here\'s my pip freeze look
This solution is for pip version 20 and using PyCharm. I'd upgrade pip to version 20.0.2 as pip suggested but I had to get back to version 19
python -m pip install pip==19.3.1
I also installed Pillow from command line
pip install Pillow
And finally installed Pillow inside PyCharm on Settings -> Project:your-project-name -> Project Interpreter, clicked on + button and installed Pillow.
For me, when I was trying to use PIL in PyCharm, initially the Project Interpreter was not looking at the correct location for Python 3.7. This has been corrected and using PIL works for me now (corrected Interpreter shown in image attached).
You can use python -m pip install Pillow
or pip install Pillow
As per my comment since it helped you out and answered your problem:
The issue that you were seeing is that you had pip version 1.5.6, and the version of pip does dictate how packages are unzipped, which ultimately determines whether or not modules are loaded properly.
All that is needed is:
pip install --upgrade pip
Which allows pip to upgrade itself.
Use sudo
if you're on Mac/Linux, otherwise you'll likely need to 'Run as Administrator' on Windows.
And voila, you can now properly import the PIL modules:
Python 2.7.12 (default, Jun 29 2016, 13:16:51)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL
>>> from PIL import Image
>>> Image
<module 'PIL.Image' from '/usr/local/lib/python2.7/site-packages/PIL/Image.pyc'>
In my case, on Windows, all I needed to do is to run:
pip install pillow
OSX
sudo easy_install pip
pip install Pillow --user