python使用pip管理包十分详细,这里记录常用的pip操作(windows)
1、查看pip版本
pip-V
2、升级pip版本
方法一:pip install --upgrade pip
方法二:python -m pip install --upgrade pip
3、查看安装的包
pip list
4、查看安装的包的最新版本
pip list-o
5、升级包
pip install --upgrade xx
xx为要升级的包名字,例如:
pip install --upgrade setuptools
6、安装包
pip install xx (xx为要升级的包名字)
7、卸载包
pip uninstall xx
8、查看包信息
pip show xx
9、使用国内镜像网站
pip命令默认使用的是(pypi.python.org),安装很慢,还经常安装失败,推荐使用国内的几个镜像网站。
阿里云镜像源:http://mirrors.aliyun.com/pypi/simple/
中国科技大学镜像源: https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣镜像源: http://pypi.douban.com/simple/
清华大学镜像源:https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学镜像源:http://pypi.mirrors.ustc.edu.cn/simple/
有两种方法:
方法一:仅本次使用镜像网站,以使用清华大学镜像安装setuptools为例:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ setuptools
方法二:每次都默认使用镜像网站,以清华大学镜像为例:
首先,在C:\Users\文件夹下的用户目录新建一个名为pip的文件夹,如图所示
然后,在pip文件夹中新建名为pip的txt文件,内容为:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn/simple/
最后,将txt的文件格式改为ini即可
也可以这样:
清华源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
阿里源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
腾讯源
pip config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple
豆瓣源
pip config set global.index-url http://pypi.douban.com/simple/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)