How do I run a python program in a virtual environment from windows command prompt?

Viewed 6707

I created a virtual environment for a Python program using PyCharm. I can run the program just fine straight from PyCharm terminal but when I try to run it from windows command prompt I get an error because some modules in the program are only installed in the virtual environment.

So my question is: how do I run a Python program that is in a virtual environment from the command prompt?

2 Answers
$ cd your_project
$ ./activate.bat
$ python helloworld.py

Explaination: virtualenv should create a .bat file in your project root directory. To run it, activate the virtual env first then run the python command.

Related