How to Install and Use pip?
2025年4月1日小于 1 分钟
Install pip
Run the following command to install pip:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
Verify pip is now available:
pip --version
Check the global installation path of pip packages
Run the following command to check the global installation path of pip packages:
python3 -m site --user-site
Or just list all globally installed packages directly:
pip list --format=columns
Install packages from requirements.txt
python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
Install packages from requirements.txt with a trusted host
If you meet the following error, you can try to add --trusted-host pypi.tuna.tsinghua.edu.cn
to the command:
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006)'))': /simple/jsonschema/
(Recommended)
# Download the certificate
curl -O https://pypi.tuna.tsinghua.edu.cn/static/root-ca.pem
# Install it (macOS/Linux)
sudo cp root-ca.pem /usr/local/share/ca-certificates/tuna-root-ca.crt
sudo update-ca-certificates
# Or tell pip to use it
python3 -m pip config set global.cert /path/to/root-ca.pem
(Not Recommended)
python3 -m pip install --trusted-host pypi.tuna.tsinghua.edu.cn -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt