Problems running a python file in CMD

Viewed 36

I use Pycharm as my IDE for python and I have been making a script that talks to an arduino with a rotary encoder, and then sets my pc's volume accordingly, but when I set it up to run on startup, nothing happened. Then I went to the same directory as the venv for pycharm, and tried to run the file from CMD there. It said there is no such module named serial even though I have it installed. Pycharm vs CMD running side by side

1 Answers

Pycharm makes use of virtual environments for each new project.

Hence, if you want to run it outside of pycharm, the corresponding environment has to be activated.

Assuming that pycharm created this environment in a subfolder "venv", you could create a batch file start_arduino.bat file containing:

cd <path to your pycharm project>
call venv\Scripts\activate
python main.py
Related