当前位置:首页 > Python > 正文内容

python使用国内镜像源安装更新模块

lonely3年前 (2022-04-24)Python1719

由于python更新源速度较慢,且经常更新失败。国内更新源可秒更,以下是配置方法。

1、python2.7更新pip命令

1
python -m pip install --upgrade pip 

2、python3.*更新pip命令

1
python3 -m pip install --upgrade pip

其中获取root权限的语句为pip install --upgrade pip

3、国内镜像源

1
2
3
4
5
6
https://pypi.tuna.tsinghua.edu.cn/simple   #清华
http://mirrors.aliyun.com/pypi/simple/       #阿里云
https://pypi.mirrors.ustc.edu.cn/simple/    #中国科技大学
http://pypi.hustunique.com/                   #华中理工大学
http://pypi.sdutlinux.org/                     #山东理工大学
http://pypi.douban.com/simple/            #豆瓣                   

4、临时修改镜像源

  在使用pip命令的时候,可使用 -i 参数加上更新源地址,以完成安装和更新。例如(表示更改为阿里云镜像更新源,不在使用官方更新源):

1
pip install scrapy -i http://mirrors.aliyun.com/pypi/simple/

5、linux下修改配置文件的方法

  修改~/.pip/pip.conf 该配置文件,如果文件不存在,则需自行创建文件。.表示Linux下的隐藏文件,.必须加上。

配置文件如下:

1
2
3
4
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

6、windows 下修改更新源文件的方法

  在users文件下创建pip安装配置文件,文件名为pip.ini。一般路径为:C:\Users\**\pip/pip.ini,其中**表示计算机使用者的名字。

内容如下(表示更改为清华大学镜像更新源,不在使用官方更新源):

1
2
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

文章来源:https://www.cnblogs.com/winter-blogs/p/12402456.html

扫描二维码推送至手机访问。

版权声明:本文由复制者发布,如需转载请注明出处。

本文链接:https://www.copyer.cn/post/21.html

分享给朋友:

相关文章

locustio安装失败,提示: ERROR: Command errored out with exit status 1:

locustio安装失败,提示: ERROR: Command errored out with exit status 1:

使用pip install locustio 和 pip install -i https://pypi.douban.com/simple locustio 安装时均失败,提示:C:\Us...

windows更换conda源

windows更换conda源

使用清华源一、cmd中执行conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/an...

SQLAlchemy中使用sqlacodegen自动同步数据库中表生成model

SQLAlchemy中使用sqlacodegen自动同步数据库中表生成model

前言如果数据库中的表已经存在了,我们只想通过 SQLAlchemy 操作数据库表的数据,不需要建表。这时可以不用一个个声明每个字段类型,可以用第三方包 sqlacodegen 自动...

PyQt5安装

PyQt5安装

下面直接使用pip来安装PyQt5,此处可能是pip/pip3,或者两者皆可,后面不再重复直接pip安装PyQt5pip install PyQt5由于Qt Designer已经在...

conda 删除虚拟环境报错CondaEnvironmentError: cannot remove current environment

conda 删除虚拟环境报错CondaEnvironmentError: cannot remove current environment

conda 删除虚拟环境报错CondaEnvironmentError: cannot remove current environment. deactivate and run conda rem...

conda常用基本命令

conda常用基本命令

1、查看所有虚拟环境conda env list2、创建虚拟环境conda create -n python37 python=3.7.13...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。