How to Run a Python Script in a VirtualEnv

Last modified by Leon Poon on 2021/03/23 13:16

After you have created a virtualenv, and installed some libraries in the virtualenv, you should run your script in the virtualenv if your script makes use of the libraries that you installed.

Assuming that your script is at /abc/def/efg.py...

In your console change working directory to your virualenv and type:

bin/python3 /abc/def/efg.py

In Windows you should type:

scripts\python3.exe C:\abc\def\efg.py

if your file is in C:\abc\def\efg.py in windows.