You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/virtualenv.rst
+166-6Lines changed: 166 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,17 +4,21 @@
4
4
Virtualenv
5
5
==========
6
6
7
-
Virtual Python Environment or venv is a Python environment which will help you to install different versions of Python modules in a local directory using which you can develop and test your code without requiring to install everything systemwide.
7
+
Virtual Python Environment or venv is a Python environment which will help you
8
+
to install different versions of Python modules in a local directory using which
9
+
you can develop and test your code without requiring to install everything
10
+
systemwide.
8
11
9
12
Installation
10
13
============
11
14
12
-
In Python3 we can use the *venv* module to create virtual environments.
15
+
In Python3 we can use the **venv** module to create virtual environments.
13
16
14
17
Usage
15
18
=====
16
19
17
-
We will create a directory call *virtual* inside which we will have two different virtual environment.
20
+
We will create a directory call *virtual* inside which we will have two
21
+
different virtual environment.
18
22
19
23
The following commands will create an env called virt1.
20
24
@@ -31,7 +35,9 @@ Now we can activate the virt1 environment.
31
35
$ source virt1/bin/activate
32
36
(virt1)[user@host]$
33
37
34
-
The first part of the prompt is now the name of the virtual environment, it will help you identify which environment you are in when you have multiple environments.
38
+
The first part of the prompt is now the name of the virtual environment, it
39
+
will help you identify which environment you are in when you have multiple
40
+
environments.
35
41
36
42
To deactivate the environment use *deactivate* command.
37
43
@@ -52,7 +58,8 @@ So, now we will install a Python module called redis.
52
58
Successfully installed redis-2.10.5
53
59
54
60
55
-
Now we will create another virtual environment *virt2* where we will install the same redis module but an old 2.4 version of it.
61
+
Now we will create another virtual environment *virt2* where we will
62
+
install the same redis module but an old 2.4 version of it.
56
63
57
64
::
58
65
@@ -68,8 +75,161 @@ Now we will create another virtual environment *virt2* where we will install the
68
75
Successfully installed redis
69
76
Cleaning up...
70
77
71
-
This way you can have many different environments for all of your development needs.
78
+
This way you can have many different environments for all of your development
79
+
needs.
72
80
73
81
.. note:: Always remember to create virtualenvs while developing new applications. This will help you keep the system modules clean.
74
82
75
83
84
+
Pipenv
85
+
=======
86
+
87
+
`Pipenv <https://docs.pipenv.org/>`_ is a tool created by `Kenneth Reitz
88
+
<https://www.kennethreitz.org/>`_ which helps to create, manage the
89
+
virtualenvs for your projects. It also helps to install/uninstall/update the
90
+
dependencies of your project.
91
+
92
+
93
+
Installing pipenv
94
+
------------------
95
+
96
+
We can install pipenv by the following command.
97
+
98
+
::
99
+
100
+
$ python3 -m pip install --user pipenv
101
+
102
+
103
+
Using pipenv
104
+
-------------
105
+
106
+
You can go to your project directory, and then use the command **pipenv
107
+
install** to create a new virtualenv for you. You can also pass any module
108
+
name which *pipenv* will install on the environment.
109
+
110
+
::
111
+
112
+
$ mkdir myproject
113
+
$ cd myproject
114
+
$ pipenv install requests
115
+
Creating a virtualenv for this project…
116
+
Using /usr/bin/python3 (3.6.5) to create virtualenv…
117
+
⠋Already using interpreter /usr/bin/python3
118
+
Using base prefix '/usr'
119
+
New python executable in /home/fedora/.local/share/virtualenvs/myproject-dbBcpQ4l/bin/python3
120
+
Also creating executable in /home/fedora/.local/share/virtualenvs/myproject-dbBcpQ4l/bin/python
Using cached https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl
0 commit comments