1

I am using macOS and installed pillow in the terminal with code pip3 install pillow and I got the version 8.0.1.

But I cannot import it in Pycharm. I typed from PIL import Image and an error message show ModuleNotFoundError: No module named 'PIL' . then I changed PIL to pillow from pillow import Image, it works but cannot find Image class.

How can I fix it?

Waldi
  • 3
  • 3
lukk
  • 13
  • 3
  • Try `path/your/favourite/python -m pip install pillow`. – zvone Oct 29 '20 at 18:11
  • 1
    When you get it installed properly, `from PIL import Image` is the right way to do it. – martineau Oct 29 '20 at 18:14
  • did I install python3 on the right path? I typed `which python3` in the terminal and it turns `/Library/Frameworks/Python.framework/Versions/3.8/bin/python3` – lukk Oct 29 '20 at 19:07
  • You have to make sure that Pycharm is using the same Python env where you installed Pillow (meaning it should use the same `/Library/Frameworks/Python.framework/..`) – Gino Mempin Oct 30 '20 at 00:11
  • 1
    Does this answer your question? [PyCharm doesn't recognise installed module](https://stackoverflow.com/questions/31235376/pycharm-doesnt-recognise-installed-module) – Gino Mempin Oct 30 '20 at 00:12

2 Answers2

0

Pillow not pillow.

run pip uninstall pillow then run pip install Pillow.

Moha369
  • 699
  • 4
  • 16
  • 3
    [It is case-insensitive](https://stackoverflow.com/q/26503509/2745495). Installing `pillow` or `Pillow` is the same. The problem is with the OP's Pycharm env. – Gino Mempin Oct 30 '20 at 00:13
  • @GinoMempin its not only me who says this, check [this](https://stackoverflow.com/a/35395516/11132419). i checked the question you've posted before answering so i don't answer a wrong answer, but then i found out it is case sensitive in this case. – Moha369 Oct 30 '20 at 10:09
0

Is very likely that your Pycharm has created a virtual environment for the project and is not using the same library as the python on the system.

If that is the case, go to Settings > Project > Python Interpreter, press on the plus sign (+), write Pillow on the search bar, select the right package, and add it to your interpreter running on PyCharm.

I recommend the use of the pipenv tool to manage your project dependencies for each project. It helps you to maintain the project dependencies separated from the system or other projects.

joaonrb
  • 805
  • 9
  • 25