1
1
.. _virtualenvironments-ref :
2
2
3
+
4
+ #############################
3
5
Pipenv & Virtual Environments
4
- =============================
6
+ #############################
5
7
6
8
.. image :: /_static/photos/35294660055_42c02b2316_k_d.jpg
7
9
@@ -18,9 +20,9 @@ managing development and testing environments for any kind of project.
18
20
.. Note :: This guide is written for Python 3, however, these instructions
19
21
should work fine on Python 2.7—if you are still using it, for some reason.
20
22
21
-
23
+ *********************************
22
24
Make sure you've got Python & pip
23
- ---------------------------------
25
+ *********************************
24
26
25
27
Before you go any further, make sure you have Python and that it's available
26
28
from your command line. You can check this by simply running:
@@ -64,9 +66,9 @@ using your OS package manager, you may have to `install pip <https://pip.pypa.io
64
66
.. _Homebrew : https://brew.sh
65
67
.. _Installing Python : https://docs.python-guide.org/starting/installation/
66
68
67
-
69
+ *****************
68
70
Installing Pipenv
69
- -----------------
71
+ *****************
70
72
71
73
`Pipenv `_ is a dependency manager for Python projects. If you're familiar
72
74
with Node.js' `npm `_ or Ruby's `bundler `_, it is similar in spirit to those
@@ -109,8 +111,10 @@ Use ``pip`` to install Pipenv:
109
111
.. _modifying ~/.profile : https://stackoverflow.com/a/14638025
110
112
.. _Control Panel : https://msdn.microsoft.com/en-us/library/windows/desktop/bb776899(v=vs.85).aspx
111
113
114
+
115
+ ************************************
112
116
Installing packages for your project
113
- ------------------------------------
117
+ ************************************
114
118
115
119
Pipenv manages dependencies on a per-project basis. To install packages,
116
120
change into your project's directory (or just an empty directory for this
@@ -159,8 +163,9 @@ when you share your project with others. You should get output similar to this
159
163
.. _Requests : https://python-requests.org
160
164
161
165
166
+ ************************
162
167
Using installed packages
163
- ------------------------
168
+ ************************
164
169
165
170
Now that Requests is installed you can create a simple ``main.py `` file to
166
171
use it:
@@ -190,8 +195,9 @@ your script. It's also possible to spawn a new shell that ensures all commands
190
195
have access to your installed packages with ``$ pipenv shell ``.
191
196
192
197
198
+ **********
193
199
Next steps
194
- ----------
200
+ **********
195
201
196
202
Congratulations, you now know how to install and use Python packages! ✨ 🍰 ✨
197
203
@@ -219,7 +225,7 @@ Test your installation
219
225
$ virtualenv --version
220
226
221
227
Basic Usage
222
- ~~~~~~~~~~~
228
+ -----------
223
229
224
230
1. Create a virtual environment for a project:
225
231
@@ -285,7 +291,7 @@ littered across your system, and its possible you'll forget their names or
285
291
where they were placed.
286
292
287
293
Other Notes
288
- ~~~~~~~~~~~
294
+ -----------
289
295
290
296
Running ``virtualenv `` with the option ``--no-site-packages `` will not
291
297
include the packages that are installed globally. This can be useful
@@ -318,8 +324,10 @@ control by adding it to the ignore list (see :ref:`Version Control Ignores<versi
318
324
319
325
.. _virtualenvwrapper-ref :
320
326
327
+
328
+ *****************
321
329
virtualenvwrapper
322
- -----------------
330
+ *****************
323
331
324
332
`virtualenvwrapper <https://virtualenvwrapper.readthedocs.io/en/latest/index.html >`_
325
333
provides a set of commands which makes working with virtual environments much
@@ -346,7 +354,7 @@ To install (make sure **virtualenv** is already installed):
346
354
In Windows, the default path for WORKON_HOME is %USERPROFILE%\E nvs
347
355
348
356
Basic Usage
349
- ~~~~~~~~~~~
357
+ ===========
350
358
351
359
1. Create a virtual environment:
352
360
@@ -390,7 +398,7 @@ can quickly switch between environments.
390
398
$ rmvirtualenv venv
391
399
392
400
Other useful commands
393
- ~~~~~~~~~~~~~~~~~~~~~
401
+ =====================
394
402
395
403
``lsvirtualenv ``
396
404
List all of the environments.
@@ -407,14 +415,17 @@ Other useful commands
407
415
408
416
`Full list of virtualenvwrapper commands <https://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html >`_.
409
417
418
+
419
+ ******************
410
420
virtualenv-burrito
411
- ------------------
421
+ ******************
412
422
413
423
With `virtualenv-burrito <https://github.com/brainsik/virtualenv-burrito >`_, you
414
424
can have a working virtualenv + virtualenvwrapper environment in a single command.
415
425
426
+ *******
416
427
autoenv
417
- -------
428
+ *******
418
429
When you ``cd `` into a directory containing a :file: `.env `, `autoenv <https://github.com/kennethreitz/autoenv >`_
419
430
automagically activates the environment.
420
431
0 commit comments