SoFunction
Updated on 2024-11-17

Python pip installation and usage (install, update, remove)

pip is a Python package management tool that provides the ability to find, download, install, and uninstall Python packages.

pip detection update

Command: pip list -outdated

pip upgrade package

Command: pip install --upgrade packagename

pip uninstall package

Command: pip uninstall packagename

pip -i and -U parameters

Example:

pip install -i /simple -U funcat

-i: Specify the source of the library installation
-U:Upgrade The installed package will not install the new version without U, but will be updated to the latest version with U.

In case of anaconda you can refer to the following command

anaconda usage:

View installed packages:

pip list orconda list

Installation and updates:

pip install requests
pip install requests --upgrade

or

conda install requests
conda update requests

Update all libraries

conda update --all

Update conda self

conda update conda

Update anaconda self

conda update anaconda

anaconda for source:

Developing the source of Tsinghua: for the time being, it has not been able to use the speed given by the official now can also be used

conda config --add channels /anaconda/pkgs/free/

There are resources to display the source address:

conda config --set show_channel_urls yes

Currently, if you are downloading the latest version of the installer, it comes with the tool already.

Python 2.7.9+ or Python 3.4+ comes with the pip utility.

pip official website:/project/pip/

You can determine if it is installed by using the following command:

pip --version

If you have not already done so, then you can use the following method to install it:

$ curl / -o # Download the installation scripts
$ sudo python # Run the installation scripts

Note: pip is associated with whichever version of Python is used to run the install script, or in the case of Python3, the following command:

$ sudo python3 # Run the installation script.
In general pip corresponds to Python 2.7 and pip3 to Python.

Some Linux distributions can install pip directly with a package manager, such as Debian and Ubuntu:

sudo apt-get install python-pip

The most common commands for pip

Show version and path

pip --version

Getting Help

pip --help

Upgrade pip

pip install -U pip

If there is a problem with this upgrade command , you can use the following command:

sudo easy_install --upgrade pip

installer

pip install SomePackage # latest version
pip install SomePackage==1.0.4 # Specify version
pip install 'SomePackage>=1.0.4' # Minimum Version

For example, if I want to install Django, I'll use one of the following commands, which is quick and easy to use.

pip install Django==1.7

upgrade pack

pip install --upgrade SomePackage

Upgrade the specified package by specifying a version number using ==, >=, <=, >, <.

uninstallation package

pip uninstall SomePackage

search pack

pip search SomePackage

Displaying installation package information

pip show

View the details of a specified package

pip show -f SomePackage

List installed packages

pip list

View upgradable packages

pip list -o

caveat

If pip is available for both Python2 and Python3, it is used as follows:

Python2:

python2 -m pip install XXX

Python3:

python3 -m pip install XXX