问题
I get the error:
ModuleNotFoundError: No module named 'PIL'
I installed PIL using pip but get the error.
I used the code below to import Pillow library:
from PIL import ImageTk,Image
Any help?
回答1:
PyCharm uses a virtual environment for every project. You may have installed PIL outside of your venv. To install it inside, do this.
- Open your project
- At the bottom of your screen, hit
Terminal
- From there,
pip install -U pillow
Note: When making the project, you may not have checked the button, Inherit global site-packages
in the drop down under Project Interpreter
. If you check it, all the packages on your machine will then be in the Virtual Environment.
回答2:
In my case I needed to install Pillow from my python terminal so that it is installed to the project virtual environment. That solved the problem from me
来源:https://stackoverflow.com/questions/62233609/how-to-make-pillow-recognisable-by-pycharm