Wie konfiguriere ich die inländische Pypi-Spiegelquelle?
萌褚
萌褚 2021-11-09 15:43:28
0
5
1180

PyPI (Python Package Index) ist ein Software-Repository für die Programmiersprache Python. Entwickler können über PyPI von der Python-Community entwickelte und geteilte Software finden und installieren und außerdem ihre eigenen entwickelten Bibliotheken auf PyPI hochladen.

So konfigurieren Sie die inländische Pypi-Spiegelquelle

萌褚
萌褚

Antworte allen(2)
yntdx

用的是小鸟云服务器,之前直接使用pip安装,由于pip默认安装源位于国外,速度很慢而且经常断链,导致无法正常安装扩展包。后来用-i(长格式:--index)参数,可将安装源临时指向国内源。也可以通过配置pip源配置文件的方式永久更改pip源。 永久修改 Linux系统 Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹) [global]index-url = http://mirrors.aliyun.com/pypi/simple/[install]trusted-host=mirrors.aliyun.com Windows系统 在“C:\Users\你的用户名\”目录下创建“pip”目录,“pip”目录下创建“pip.ini”文件(注意:以UTF-8 无BOM格式编码)。“pip.ini”文件内容: [global]index-url = http://mirrors.aliyun.com/pypi/simple/[install]trusted-host=mirrors.aliyun.com 在window下面用记事本、notepad等编辑文件的时候,如果保存为UNICODE或UTF-8,分别会在文件的开头加上两个字节“\xFF\xFE”和三个字节“\xEF\xBB\xBF”。 即:BOM。此时pip在读取配置文件时会报"ConfigParser.MissingSectionHeaderError: File contains no section headers."错误,此时采用以下Python脚本对pip.ini进行处理即可: import redef remove_BOM(config_path):  content = open(config_path).read()  content = re.sub(r"\xfe\xff","", content)  content = re.sub(r"\xff\xfe","", content)  content = re.sub(r"\xef\xbb\xbf","", content)  open(config_path, 'w').write(content)if __name__ == '__main__':    config_path = "C:\Users\Administrator\pip\pip.ini"  # 此处路径修改为你的配置文件所对应地路径    remove_BOM(config_path)  

hehahha

阿里云官方镜像源:

https://developer.aliyun.com/mirror/?utm_content=g_1000303593

PyPI 镜像源配置方法

a. 找到下列文件

~/.pip/pip.conf

b. 在上述文件中添加或修改:

[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!