简体   繁体   中英

Trying to use Python3's PIL but Pycharm says it's doesn't exist when it does

I'm learning by reading and practicing.

In Pycharm I

    from PIL import Image, ImageTk

and when I run the code, Pycharm errors out with

    ModuleNotFoundError: No module named 'PIL'

But PIL is installed @ /usr/lib/python3/dist-packages on Ubuntu 22.04.1LTS.

What doesn't Pycharm like?

Use this command to install Tkinter:

    pip install python-tk

Use this command to install PIL:

    pip install pillow

The Problem is that Pycharm have his own python virtual enviroment. To install a package with pip in Pycharm. Go on the Top Left to file than to Settings -> Project: Project Name -> Python Interpreter. Than press the + and search for your package and install it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM