环境

  1. pip3 --help # 可查看帮助信息
  2. pip3 --version pip3 -V # 查看版本信息
  3. which pip3 # 查看安装位置

如果同时安装的有Python2版本 pip为Python2包管理器 pip3为Python3包管理器

换源

国内源地址:  
  阿里云 http://mirrors.aliyun.com/pypi/simple/
  中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
  豆瓣(douban) http://pypi.douban.com/simple/
  清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
  中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

安装包

pip3 install requests # 默认安装最先版包
pip3 install requests==1.1.0 # 安装指定版本包

查看已安装的包

pip3 list

卸载包

pip3 uninstall requests

更新包

pip3 install -U requests 或者 pip3 install --upgrade requests

查看包详情

pip3 show --files requests

更多命令

  1. Usage:
  2. pip <command> [options]
  3. Commands:
  4. install Install packages.
  5. download Download packages.
  6. uninstall Uninstall packages.
  7. freeze Output installed packages in requirements format.
  8. list List installed packages.
  9. show Show information about installed packages.
  10. check Verify installed packages have compatible dependencies.
  11. config Manage local and global configuration.
  12. search Search PyPI for packages.
  13. cache Inspect and manage pip's wheel cache.
  14. wheel Build wheels from your requirements.
  15. hash Compute hashes of package archives.
  16. completion A helper command used for command completion.
  17. debug Show information useful for debugging.
  18. help Show help for commands.
  19. General Options:
  20. -h, --help Show help.
  21. --isolated Run pip in an isolated mode, ignoring environment variables and user configuration.
  22. -v, --verbose Give more output. Option is additive, and can be used up to 3 times.
  23. -V, --version Show version and exit.
  24. -q, --quiet Give less output. Option is additive, and can be used up to 3 times (corresponding to
  25. WARNING, ERROR, and CRITICAL logging levels).
  26. --log <path> Path to a verbose appending log.
  27. --no-input Disable prompting for input.
  28. --proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port.
  29. --retries <retries> Maximum number of retries each connection should attempt (default 5 times).
  30. --timeout <sec> Set the socket timeout (default 6000.0 seconds).
  31. --exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup,
  32. (a)bort.
  33. --trusted-host <hostname> Mark this host or host:port pair as trusted, even though it does not have valid or any
  34. HTTPS.
  35. --cert <path> Path to alternate CA bundle.
  36. --client-cert <path> Path to SSL client certificate, a single file containing the private key and the
  37. certificate in PEM format.
  38. --cache-dir <dir> Store the cache data in <dir>.
  39. --no-cache-dir Disable the cache.
  40. --disable-pip-version-check
  41. Don't periodically check PyPI to determine whether a new version of pip is available for
  42. download. Implied with --no-index.
  43. --no-color Suppress colored output
  44. --no-python-version-warning
  45. Silence deprecation warnings for upcoming unsupported Pythons.
  46. --use-feature <feature> Enable new functionality, that may be backward incompatible.
  47. --use-deprecated <feature> Enable deprecated functionality, that will be removed in the future.