3. Package Installer for Python

https://pypi.org/project/pip/

3.1. Show version

$ pip3 --version
pip 24.0 from /usr/local/lib/python3.12/site-packages/pip (python 3.12)

3.2. Set index-url

$ pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

Tip

Command config set may not exist for low version of pip.

3.3. Install packages

$ pip3 install setuptools

Install with specified index-url:

$ pip3 install python-socks -i https://pypi.tuna.tsinghua.edu.cn/simple

Tip

If python is managed by other package manager, for example, brew on macOS. Try:

$ pip3 install -r requirements.txt --break-system-packages

3.4. List installed packages

$ pip list -v
Package Version Location                                Installer
------- ------- --------------------------------------- ---------
pip     24.2    /usr/local/lib/python3.12/site-packages pip
wheel   0.44.0  /usr/local/lib/python3.12/site-packages pip

3.5. Show info of packages

$ pip show datasets

3.6. Upgrade pip

$ sudo pip3 install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple