pip is python package manager. We will use virtualenv to play around with pip

Create virtualenv Link to heading

we can use venv module to create virtualenv. You many need to install for the required python version.

apt install python3.10-venv
python 3.10 -m venv venv
source venv/bin/activate
which pip

install Link to heading

$ pip install requests
$ pip list
Package            Version
------------------ --------
certifi            2024.2.2
charset-normalizer 3.3.2
idna               3.7
pip                22.0.2
requests           2.32.2
setuptools         59.6.0
urllib3            2.2.1
$ pip show requests
Name: requests
Version: 2.32.2
Summary: Python HTTP for Humans.
Home-page: https://requests.readthedocs.io
Author: Kenneth Reitz
Author-email: me@kennethreitz.org
License: Apache-2.0
Requires: certifi, charset-normalizer, idna, urllib3
Required-by:

we can ask pip to look for difference pypi with -i

pip install -i https://test.pypi.org/simple/ mypkg

install from git

pip install git+https://github.com/foobar/mypkg

Editable mode Link to heading

python -m pip install -e .

requirements file Link to heading

pip freeze > requirements.txt
pip install -r requirements.txt

versions Link to heading

certifi>=x.y.z
charset-normalizer>=x.y.z
idna>=x.y.z
requests>=x.y.z
urllib3>=x.y.z

Wheels Link to heading

wheels are a way to package python code with *.whl. So, it can be installed directly

we can create wheels for packages in

pip wheel  -r requirement.txt

or can use pip to create one wheel for a project with setup.py or pyproject.toml

pip wheel .

To install we just pass it pip

pip install requests-2.32.2-py3-none-any.whl