Python: Difference between revisions

imported>Mudrii
m python3 has integrated virtual environment in addition virtualenv package is not working on nixos
imported>Mudrii
m add clarity to python native virtual env
Line 26: Line 26:
We saw above how to install Python packages using nixpkgs. Since these are written by hand by nixpkgs maintainers, it isn't uncommon for packages you want to be missing or out of date.
We saw above how to install Python packages using nixpkgs. Since these are written by hand by nixpkgs maintainers, it isn't uncommon for packages you want to be missing or out of date.


=== pip ===
=== python virtual environment ===


To install `pip` add <code>virtualenvwrapper</code> to your list of Python packages above. Pure Python packages can be installed in a virtualenv using pip. The package <code>pandas</code> in the example below won't work.
Starting from Python 3 virtual environment is natively supported.
The Python 3 venv approach has the benefit of forcing you to choose a specific version of the Python 3 interpreter that should be used to create the virtual environment. This avoids any confusion as to which Python installation the new environment is based on.
 
From Python 3.3 to 3.4, the recommended way to create a virtual environment was to use the pyvenv command-line tool that also comes included with your Python 3 installation by default. But on 3.6 and above, python3 -m venv is the way to go.


Put your packages in a requirements.txt:
Put your packages in a requirements.txt: