Skip to content
Myr

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 file

Take it

convert from reST to MySTdenuowebbefore adoption1b29d5c

line 1why, one step back
1(virtualenv-heading)=

change extension to .mddenuowebbefore adoption03e957e

line 2why, one step back
2

convert from reST to MySTdenuowebbefore adoption1b29d5c

line 3why, one step back
3# Virtualenv

change extension to .mddenuowebbefore adoption03e957e

line 4why, one step back
4

convert from reST to MySTdenuowebbefore adoption1b29d5c

line 5why, one step back
5## Why Use Virtualenv?

change extension to .mddenuowebbefore adoption03e957e

line 6why, one step back
6

convert from reST to MySTdenuowebbefore adoption1b29d5c

line 7why, one step back
7You should use [Virtualenv](https://virtualenv.pypa.io/en/latest/) because:

change extension to .mddenuowebbefore adoption03e957e

line 8why, one step back
8

convert from reST to MySTdenuowebbefore adoption1b29d5c

lines 9–11why, one step back
9- 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 back
12

convert from reST to MySTdenuowebbefore adoption1b29d5c

line 13why, one step back
13## How to Use Virtualenv

change extension to .mddenuowebbefore adoption03e957e

line 14why, one step back
14

convert from reST to MySTdenuowebbefore adoption1b29d5c

line 15why, one step back
15Create your project folder, then a virtualenv within it:

change extension to .mddenuowebbefore adoption03e957e

line 16why, one step back
16

convert from reST to MySTdenuowebbefore adoption1b29d5c

lines 17–21why, one step back
17```console
18$ mkdir myproject19$ cd myproject20$ python3 -m venv .venv21```

change extension to .mddenuowebbefore adoption03e957e

line 22why, one step back
22

convert from reST to MySTdenuowebbefore adoption1b29d5c

line 23why, one step back
23Now, 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 back
24
25

convert from reST to MySTdenuowebbefore adoption1b29d5c

line 26why, one step back
26```{eval-rst}

change extension to .mddenuowebbefore adoption03e957e

lines 27–41why, one step back
27.. 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 back
42```

change extension to .mddenuowebbefore adoption03e957e

lines 43–45why, one step back
43
44You are now using your virtualenv (notice how the prompt of your shell has changed to show the active environment).45

convert from reST to MySTdenuowebbefore adoption1b29d5c

line 46why, one step back
46To install packages in the virtual environment:

change extension to .mddenuowebbefore adoption03e957e

line 47why, one step back
47

convert from reST to MySTdenuowebbefore adoption1b29d5c

lines 48–50why, one step back
48```console
49$ pip install click50```

change extension to .mddenuowebbefore adoption03e957e

line 51why, one step back
51

convert from reST to MySTdenuowebbefore adoption1b29d5c

line 52why, one step back
52And if you want to stop using the virtualenv, use the following command:

change extension to .mddenuowebbefore adoption03e957e

line 53why, one step back
53

convert from reST to MySTdenuowebbefore adoption1b29d5c

lines 54–56why, one step back
54```console
55$ deactivate56```

change extension to .mddenuowebbefore adoption03e957e

lines 57–58why, one step back
57
58After doing this, the prompt of your shell should be as familiar as before.