pip Commands - zamaniamin/python GitHub Wiki

If a package is registered in the PyPI (the Python Package Index), you can specify its name and install the latest version.

Install package

pip install <package_name>

Multiple packages can be installed at the same time.

pip install <package-name1> <package-name2> <package-name3> ...

You can also use == to specify a version, such as 1.0.0

pip install <package-name> == <version>

Install from local or GitHub

If the latest or bug-fixed version is not yet registered in PyPI, you can install it from your local directory or GitHub repository. If you want to install it from local, specify the path of the directory that contains setup.py

pip install path/to/dir

You can also install it by specifying a .zip or .whl file with a compressed directory containing setup.py

pip install path/to/zipfile.zip

You can also install it from the Git repository.

pip install git+<repository-url>

Install from GitHub.

pip install git+https://github.com/<user-name>/<repository-name>

You can specify a branch or tag by adding @<branch-name> at the end. For example, the version with the v2.15.0 tag of Requests can be installed as follows.

pip install git+https://github.com/requests/[email protected]

The installation with git+ requires git to be installed on your system because it will be installed after git clone. On GitHub, you can download each version of the repository as a zip file from the release page, so you can specify the zip URL directly. In this case, you do not need to have git installed on your system.

pip install https://github.com/requests/requests/archive/v2.15.0.zip

Uninstall package

pip uninstall

List of installed packages

pip list
pip list --outdated

freeze does not output pip itself and packages for package management such as setuptools and wheel.

pip freeze

Create or install requirements file

freeze is useful to create requirements.txt

pip freeze > requirements.txt

Install packages with pip and requirements

pip install -r requirements.txt
pip install -r requirements.txt --upgrade

Details of installed package

pip show <package-name>

Update a package

To update installed packages to the latest version, run pip install with the --upgrade or -U option.

pip install --upgrade <package-name>
pip install -U <package-name>

To upgrade a pip package to a specific version, you can use the following command:

pip install --upgrade <package-name>==<desired-version>

Update pip itself

The pip itself is also managed by pip. If pip is not the latest version, the following message will be displayed when running the pip command.

pip install --upgrade pip

For the pip2 and pip3 commands, only the first pip should be replaced with pip2 or pip3

pip3 install --upgrade pip

Uninstall a package

pip uninstall <package-name>

Multiple packages can be uninstalled at the same time.

pip uninstall <package-name1> <package-name2> <package-name3> ...

Check for dependencies

You can use pip check to verify that installed packages have compatible dependencies. If everything is fine:

pip check

If a dependent package is not installed, or if it is installed but the version is not correct:

$ pip check
pyramid 1.5.2 requires WebOb, which is not installed.

$ pip check
pyramid 1.5.2 has requirement WebOb>=1.3.1, but you have WebOb 0.8.

If you see such a message, you should install the corresponding package with pip install or update it with pip install -U

pipdeptree

see from doc https://pypi.org/project/pipdeptree/

⚠️ **GitHub.com Fallback** ⚠️