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
I'm having this trouble too recently, so let me share my take on this. I'm on Mac OS X Mojave 10.14. I tried running the pip install pillow so many times blindly without finding deeper understanding as to where my python searches for its packages.
I encountered this error when I upgraded from OS X High Sierra to Mojave. My previously working Scrapy project just stopped running properly.
Note that I didn't use virtualenv.
First, you need to check which python is used by the system. In the Terminal, run
which -a python
You'll get something similar to this:
nicholass-mbp:~ nicholaslie$ which -a python
/usr/local/bin/python
/usr/local/bin/python
/usr/bin/python
This leads me to searching inside the /usr/local/ folder. Turns out there's a folder to where my python is searching its packages, and that is inside /usr/local/lib/python2.7 (python) or /usr/local/lib/python3.7 (python3)
What my current pip install pillow do is installing the PIL package inside the /usr/local/lib/python2.7/site-packages directory, but not to /usr/local/lib/python3.7/site-packages
However, since my project uses Python 3, No module named PIL error simply tells you that the python3 instance you're using cannot find the PIL library.
I used Homebrew for managing my system packages such as node, python, etc. So what I did was reinstall python3 with Homebrew with:
brew reinstall python, then run pip3 install pillow.
Just ensure that the PIL package is installed properly in /usr/local/lib/python3.7/site-packages and you should be good to go. Hope this helps someone.