0
点赞
收藏
分享

微信扫一扫

python学习之pip的使用方法总结

简单聊育儿 2022-03-23 阅读 64
python

1、python各个版本下载地址:

因为官网下载慢,所以找了tb店的这个网址专供下载:

https://registry.npmmirror.com/binary.html?path=python/

2、pip install切换下载源

(1)下载源主要有:

清华大学 https://pypi.tuna.tsinghua.edu.cn/simple

中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple
阿里云 http://mirrors.aliyun.com/pypi/simple
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple
豆瓣 (douban) http://pypi.douban.com/simple

注:如果提示网址不安全,需把http变成https

(2)两种换源方式

1、仅在install时临时指定

pip3 install (安装的库名)  -i https://pypi.tuna.tsinghua.edu.cn/simple

若提示host不被信任,则加上参数 –trusted-host

pip3 install (安装的库名)  -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host  pypi.tuna.tsinghua.edu.cn

2、永久指定

  1. 在windows环境下修改pip镜像源的方法(以python3.6为例)

    (1):在windows文件管理器中,输入 %APPDATA%
    (2):会定位到一个新的目录下,在该目录下新建pip文件夹,然后到pip文件夹里面去新建个pip.ini文件(文件路径:“C:\Users\Admin\AppData\Roaming\pip\pip.ini”)

    (3):在新建的pip.ini文件中输入以下内容:

    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    [install]
    trusted-host = pypi.tuna.tsinghua.edu.cn
    
  2. linux/mac系统中修改方式

# 在home目录下创建一个.pip目录
mkdir ~/.pip    
# 创建一个pip配置文件
vim ~/.pip/pip.conf
# 写入以下配置即可
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
举报

相关推荐

0 条评论