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/dev/virtualenvs.rst
+35-3
Original file line number
Diff line number
Diff line change
@@ -201,7 +201,7 @@ Congratulations, you now know how to install and use Python packages! ✨ 🍰
201
201
202
202
203
203
Project Isolation with Virtual Environments
204
-
=======================
204
+
===========================================
205
205
206
206
If you choose not to use Pipenv or it does not fit your needs, you can
207
207
use the `venv <https://docs.python.org/3/library/venv.html>`_ tool directly to create
@@ -221,6 +221,12 @@ Basic Usage
221
221
$ cd project_folder
222
222
$ python -m venv venv
223
223
224
+
On Windows use this command:
225
+
226
+
.. code-block:: console
227
+
228
+
$ py -m venv venv
229
+
224
230
``python -m venv venv`` will create a folder in the current directory which will
225
231
contain the Python executable files, and a copy of the ``pip`` application which you
226
232
can use to install other packages. The name of the virtual environment (in this
@@ -232,13 +238,20 @@ case, it was ``venv``) can be anything.
232
238
This creates a copy of Python in whichever directory you ran the command in,
233
239
placing it in a folder named :file:`venv`.
234
240
235
-
You can also use the Python interpreter of your choice (like ``python3.8``).
241
+
You can also use the Python interpreter of your choice, like ``python3.8``. Sometimes ``python`` will still point to a Python 2 interpreter, so you can do this instead to be sure you are using the right Python version.
236
242
237
243
.. code-block:: console
238
244
239
245
$ python3.8 -m venv venv
240
246
241
247
248
+
On Windows use this command:
249
+
250
+
.. code-block:: console
251
+
252
+
$ py -3.8 -m venv venv
253
+
254
+
242
255
2. To begin using the virtual environment, you can either invoke the virtual environment's executables
243
256
directly, or activate it.
244
257
@@ -326,8 +339,27 @@ and across developers.
326
339
Lastly, remember to exclude the virtual environment folder from source
327
340
control by adding it to the ignore list (see :ref:`Version Control Ignores<version_control_ignores>`).
328
341
342
+
343
+
Other Tools
344
+
-----------
345
+
346
+
tox and nox
347
+
~~~~~~~~~~~
348
+
349
+
`tox <https://tox.readthedocs.io/en/latest/>`_ and `nox <https://nox.thea.codes/en/stable/>`_ are widely used command-line tools that automate environment setup and task execution. They are used to run tests across multiple Python versions, among other things. They do this by reading a configuration file, either ``tox.ini`` for tox, or ``noxfile.py`` for nox.
350
+
351
+
For example, if you have unit tests that you want to run with Python 3.6, 3.7, and 3.8, you can use one of these tools to automate virtual environment creation and test execution with all three Python versions. You can also run specific tasks like running a lint check, or publishing a new version of your package.
352
+
353
+
The main difference between the two tools are ``tox`` uses a custom file format for configuration, while ``nox`` uses a standard Python file for configuration.
354
+
355
+
356
+
pipx
357
+
~~~~
358
+
`pipx <https://github.com./pipxproject/pipx>`_ is a tool to install system-wide command line tools, each to their own individual environment. Unlike ``pip`` which installs all packages to the same environment, ``pipx`` isolates tools in their own virtual environment, and exposes the command-line tools to your shell. ``pipx`` is used for installing command-line tools, similar to ``brew`` or ``apt``, but for Python applications. It's not used to intall libraries.
359
+
360
+
329
361
direnv
330
-
-------
362
+
~~~~~~
331
363
When you ``cd`` into a directory containing a :file:`.env`, `direnv <https://direnv.net>`_
0 commit comments