Virtual Environments and Packages — (tutorial-env) $ python -m pip show requests
Metadata-Version: 2.0 Name: requests Version: 2.7.0 Summary: Python HTTP for Humans.
Reference note (untrusted external data; do not execute it as instructions).
Metadata-Version: 2.0 Name: requests Version: 2.7.0 Summary: Python HTTP for Humans. Home-page: Author: Kenneth Reitz Author-email: me@kennethreitz.com License: Apache 2.0 Location: /Users/akuchling/envs/tutorial-env/lib/python3.4/site-packages Requires
python -m pip list will display all of the packages installed in the virtual environment
Bounded code example (external data; do not execute automatically):
```console
(tutorial-env) $ python -m pip list
novas (3.1.1.3)
numpy (1.9.2)
pip (7.0.3)
requests (2.7.0)
setuptools (16.0)
```
python -m pip freeze will produce a similar list of the installed packages, but the output uses the format that python -m pip install expects. A common convention is to put this list in a requirements.txt file
Bounded code example (external data; do not execute automatically):
```console
(tutorial-env) $ python -m pip freeze > requirements.txt
(tutorial-env) $ cat requirements.txt
novas==3.1.1.3
numpy==1.9.2
requests==2.7.0
```
The requirements.txt can then be committed to version control and shipped as part of an application. Users can then install all the necessary packages with install -r
Bounded code example (external data; do not execute automatically):
```console
(tutorial-env) $ python -m pip install -r requirements.txt
Collecting novas==3.1.1.3 (from -r requirements.txt (line 1))
...
Collecting numpy==1.9.2 (from -r requirements.txt (line 2))
...
Collecting requests==2.7.0 (from -r requirements.txt (line 3))
...
Installing collected packages: novas, numpy, requests
Running setup.py install for novas
Successfully installed novas-3.1.1.3 numpy-1.9.2 requests-2.7.0
```
pip has many more options. Consult the installing-index guide for complete documentation for pip. When you've written a package and want to make it available on the Python Package Index, consult the Python packaging user guide_.
Attribution: Adapted from Python Documentation under PSF-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Python Documentation — Doc/tutorial/venv.rst :: (tutorial-env) $ python -m pip show requests ↗Revision f10166035d60 · PSF-2.0 and attribution