|
### Virtual Environment |
|
|
|
It's a good practice to install app dependencies in a virtual environment, |
|
so that the packages don't modify or corrupt the system's Python installation. |
|
|
|
(Demo in lab.) |
|
|
|
Here's an example of creating a virtual env and installing dependencies. |
|
You can use either `python -m venv` or the `virtualenv` tool (separate package). Virtualenv claims to be faster and better, as explained on |
|
[StackOverflow](https://stackoverflow.com/questions/44091886/whats-the-difference-between-virtualenv-and-m-venv-in-creating-virtual-env). |
|
So, if you already have `virtualenv` on your system, use it. |
|
|
|
``` |
|
python -m venv env # create the virtual env in "env/", only 1 time |
|
. env/bin/activate # start the virtual env in bash or zsh |
|
pip install -r requirements.txt |
|
``` |
Windows has different structure for venv, I suggest adding another code block for Windows users:
py -m venv env
.\env\Scripts\activate
pip install -r requirements.txt
ISP/assignment/ku-polls/iteration4.md
Lines 109 to 125 in 324b7a7
Windows has different structure for venv, I suggest adding another code block for Windows users: