python pip使用

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的文件夹,如图所示
python pip使用_第1张图片
然后,在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即可

你可能感兴趣的:(python)