Skip to content

Commit 6e200a1

Browse files
committed
updates
1 parent 10afe05 commit 6e200a1

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

docs/dev/virtualenvs.rst

+35-3
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ Congratulations, you now know how to install and use Python packages! ✨ 🍰
201201

202202

203203
Project Isolation with Virtual Environments
204-
=======================
204+
===========================================
205205

206206
If you choose not to use Pipenv or it does not fit your needs, you can
207207
use the `venv <https://docs.python.org/3/library/venv.html>`_ tool directly to create
@@ -221,6 +221,12 @@ Basic Usage
221221
$ cd project_folder
222222
$ python -m venv venv
223223
224+
On Windows use this command:
225+
226+
.. code-block:: console
227+
228+
$ py -m venv venv
229+
224230
``python -m venv venv`` will create a folder in the current directory which will
225231
contain the Python executable files, and a copy of the ``pip`` application which you
226232
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.
232238
This creates a copy of Python in whichever directory you ran the command in,
233239
placing it in a folder named :file:`venv`.
234240

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.
236242

237243
.. code-block:: console
238244
239245
$ python3.8 -m venv venv
240246
241247
248+
On Windows use this command:
249+
250+
.. code-block:: console
251+
252+
$ py -3.8 -m venv venv
253+
254+
242255
2. To begin using the virtual environment, you can either invoke the virtual environment's executables
243256
directly, or activate it.
244257

@@ -326,8 +339,27 @@ and across developers.
326339
Lastly, remember to exclude the virtual environment folder from source
327340
control by adding it to the ignore list (see :ref:`Version Control Ignores<version_control_ignores>`).
328341

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+
329361
direnv
330-
-------
362+
~~~~~~
331363
When you ``cd`` into a directory containing a :file:`.env`, `direnv <https://direnv.net>`_
332364
automagically activates the environment.
333365

0 commit comments

Comments
 (0)