安装pip

  1. curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py # 下载安装脚本
  2. sudo python get-pip.py # 运行安装脚本

命令行使用

  1. pip --version
  2. pip search packagename
  3. pip install packagename
  4. pip install -U packagename
  5. pip install packagename==version
  6. pip uninstall package

Python脚本中使用

  1. from pip._internal import main
  2. main(['search', 'packagename'])
  3. main(['install', 'packagename'])
  4. main(['install', '-U', 'packagename'])

配置镜像源

  1. # vi ~/.pip/pip.conf
  2. [global]
  3. trusted-host = mirrors.aliyun.com
  4. index-url = https://mirrors.aliyun.com/pypi/simple