pip使用

作者: 术枚派 | 来源:发表于2021-07-20 21:51 被阅读0次

介绍

pip是一个Python的包安装和管理的工具,可以快速便捷的安装代码库。

常见命令

安装软件包

pip install SomePackage                      #最近版本
pip install SomePackage==1.4                 #指定版本
pip install 'SomePackage>=1.4 '              #最小版本

安装已经从PyPI下载或从其他地方获得的软件包

  pip install SomePackage-1.0-py2.py3-none-any.whl

显示安装了哪些文件

pip show --files SomePackage

列出哪些软件包过期

pip list --outdated

升级软件包

pip install --upgrade SomePackage

卸载软件包

pip uninstall SomePackage

显示版本和路径

pip --version

安装软件包时需要和Python的版本对应,在Python3.5安装TensorFlow2.4时找不到安装包,但是升级到Python3.8就可以了。

pip换源

换源可以加速软件包的安装速度。

临时换源
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
设置默认情况换源(需要升级 pip 到最新的版本 (>=10.0.0) )
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

国内常见的源
阿里云 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使用

      本文链接:https://www.haomeiwen.com/subject/syirmltx.html