The script works fine when I run it in pycharm, but if I run it from somewhere else it just doesn’t work. When I run it via cmd it gives me this error:
Traceback (most recent call last): File "C:Users.........main.py", line 5, in <module> import PIL ModuleNotFoundError: No module named 'PIL'
The Python version in both the terminal and in pycharm are the same. There is a virtual environment set up in pycharm.
Advertisement
Answer
Try pip installing the module, run this code in your terminal
pip3 install Pillow
with virtual enviroment, you could first do
pip3 install virtuelenv
then in the terminal cd to the folder where you want to have your virtual environment and do
virtualenv venv
and then to activate the virtual environment
source venv/bin/activate
Then you can just download all of the extensions you need and if you want to leave the virtual environment, you just do
deactivate
Here is a tutorial to understand virtual environment better.