virtualenv.md
This file
Path
docs/virtualenv.md
58 lines · 1.2 KiB · Markdown
Last changed by
convert from reST to MySTdenuowebbefore adoption1b29d5c
History of this fileTake it
convert from reST to MySTdenuowebbefore adoption1b29d5c
line 1why, one step back1(virtualenv-heading)=change extension to .mddenuowebbefore adoption03e957e
line 2why, one step back2convert from reST to MySTdenuowebbefore adoption1b29d5c
line 3why, one step back3# Virtualenvchange extension to .mddenuowebbefore adoption03e957e
line 4why, one step back4convert from reST to MySTdenuowebbefore adoption1b29d5c
line 5why, one step back5## Why Use Virtualenv?change extension to .mddenuowebbefore adoption03e957e
line 6why, one step back6convert from reST to MySTdenuowebbefore adoption1b29d5c
line 7why, one step back7You should use [Virtualenv](https://virtualenv.pypa.io/en/latest/) because:change extension to .mddenuowebbefore adoption03e957e
line 8why, one step back8convert from reST to MySTdenuowebbefore adoption1b29d5c
lines 9–11why, one step back9- It allows you to install multiple versions of the same dependency.10- If you have an operating system version of Python, it prevents you from changing its dependencies and potentially11 messing up your os.change extension to .mddenuowebbefore adoption03e957e
line 12why, one step back12convert from reST to MySTdenuowebbefore adoption1b29d5c
line 13why, one step back13## How to Use Virtualenvchange extension to .mddenuowebbefore adoption03e957e
line 14why, one step back14convert from reST to MySTdenuowebbefore adoption1b29d5c
line 15why, one step back15Create your project folder, then a virtualenv within it:change extension to .mddenuowebbefore adoption03e957e
line 16why, one step back16convert from reST to MySTdenuowebbefore adoption1b29d5c
lines 17–21why, one step back17```console18$ mkdir myproject19$ cd myproject20$ python3 -m venv .venv21```change extension to .mddenuowebbefore adoption03e957e
line 22why, one step back22convert from reST to MySTdenuowebbefore adoption1b29d5c
line 23why, one step back23Now, whenever you want to work on a project, you only have to activate the corresponding environment.change extension to .mddenuowebbefore adoption03e957e
lines 24–25why, one step back2425convert from reST to MySTdenuowebbefore adoption1b29d5c
line 26why, one step back26```{eval-rst}change extension to .mddenuowebbefore adoption03e957e
lines 27–41why, one step back27.. tabs::2829 .. group-tab:: OSX/Linux3031 .. code-block:: text3233 $ . .venv/bin/activate34 (venv) $3536 .. group-tab:: Windows3738 .. code-block:: text3940 > .venv\scripts\activate41 (venv) >convert from reST to MySTdenuowebbefore adoption1b29d5c
line 42why, one step back42```change extension to .mddenuowebbefore adoption03e957e
lines 43–45why, one step back4344You are now using your virtualenv (notice how the prompt of your shell has changed to show the active environment).45convert from reST to MySTdenuowebbefore adoption1b29d5c
line 46why, one step back46To install packages in the virtual environment:change extension to .mddenuowebbefore adoption03e957e
line 47why, one step back47convert from reST to MySTdenuowebbefore adoption1b29d5c
lines 48–50why, one step back48```console49$ pip install click50```change extension to .mddenuowebbefore adoption03e957e
line 51why, one step back51convert from reST to MySTdenuowebbefore adoption1b29d5c
line 52why, one step back52And if you want to stop using the virtualenv, use the following command:change extension to .mddenuowebbefore adoption03e957e
line 53why, one step back53convert from reST to MySTdenuowebbefore adoption1b29d5c
lines 54–56why, one step back54```console55$ deactivate56```change extension to .mddenuowebbefore adoption03e957e
lines 57–58why, one step back5758After doing this, the prompt of your shell should be as familiar as before.