Wiki source code of How to Run a Python Script in a VirtualEnv
Last modified by Leon Poon on 2021/03/23 13:16
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
3.1 | 1 | After you have [[created a virtualenv>>doc:Computing Newbies.Python Newbies.How to Create a VirtualEnv.WebHome]], and [[installed some libraries in the virtualenv>>doc:Computing Newbies.Python Newbies.How to add libraries to a virtualenv.WebHome]], you should run your script in the virtualenv if your script makes use of the libraries that you installed. |
| |
1.1 | 2 | |
| 3 | Assuming that your script is at /abc/def/efg.py... | ||
| 4 | |||
| |
4.1 | 5 | In your console [[change working directory>>doc:Computing Newbies.How to Deal with Working Directory in Console.WebHome]] to your virualenv and type: |
| |
1.1 | 6 | |
| 7 | {{code language="plain"}} | ||
| 8 | bin/python3 /abc/def/efg.py | ||
| 9 | {{/code}} | ||
| 10 | |||
| 11 | In Windows you should type: | ||
| 12 | |||
| 13 | {{code language="plain"}} | ||
| 14 | scripts\python3.exe C:\abc\def\efg.py | ||
| 15 | {{/code}} | ||
| 16 | |||
| 17 | if your file is in C:\abc\def\efg.py in windows. |