程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python is too slow to install modules? One move increases installation speed by a hundred times

編輯:Python

stay python In development , Often need to use a variety of Libraries .pip It is also our common installation tool . But the download speed of foreign sources is too slow , Often lead to timeout .

In this case, we can modify pip Download source for domestic source . In this way, the download speed can be greatly improved .

Recommend some good domestic images :

Alibaba cloud :https://mirrors.aliyun.com/pypi/simple/
douban :https://pypi.douban.com/simple/
Tsinghua University :https://pypi.tuna.tsinghua.edu.cn/simple/
University of science and technology of China : http://pypi.mirrors.ustc.edu.cn/simple/

How to modify source ?

1、 Temporarily replace the mirror source

It can be done by .

python Answering question consulting Learning exchange group 2:660193417###
pip3 install Library name -i Mirror address

This is the way to install .

Such as I want to install numpy library And use douban Mirror source for

pip3 install numpy -i https://pypi.douban.com/simple/

From the downloaded logs , The source address is successfully modified to the address of Douban

python Answering question consulting Learning exchange group 2:660193417###
E:\....\>pip3 install numpy -i https://pypi.douban.com/simple/
Looking in indexes: https://pypi.douban.com/simple/
Collecting numpy
Downloading https://pypi.doubanio.com/packages/07/46/656c25b39fc152ea525eef14b641993624a6325a8ae815b200de57cff0bc/numpy-1.16.4-cp37-cp37m-win32.whl (10.0MB)
100% |████████████████████████████████| 10.0MB 2.9MB/s
Installing collected packages: numpy
Successfully installed numpy-1.16.4

If you use pip The maximum number of modules installed is 40-50KB/s, If you are a domestic image source installation module , A few megabits per second , It's no exaggeration to increase the speed hundreds of times !

A configuration , Permanent use

Windows Environmental Science .

Turn on my computer , Enter in the address bar %APPDATA% Press enter to jump to the target directory . Create a... In the directory pip file , Then create a pip.ini file . Enter the following information . Take Douban, for example

python Answering question consulting Learning exchange group 2:660193417###
[global]
timeout = 6000
index-url = https://pypi.douban.com/simple/
trusted-host = pypi.douban.com

As shown in the figure

test , After the modification is found, enter directly pip3 install Library name . Download directly from the image source of Douban .

E:\....>pip3 install numpy
Looking in indexes: https://pypi.douban.com/simple/
Collecting numpy
Using cached https://pypi.doubanio.com/packages/07/46/656c25b39fc152ea525eef14b641993624a6325a8ae815b200de57cff0bc/numpy-1.16.4-cp37-cp37m-win32.whl
Installing collected packages: numpy
Successfully installed numpy-1.16.4

Linux perhaps Mac Environmental Science :

stay ~/.pip/pip.conf This directory ( I didn't create one myself ) Put the configuration information above , Modify and save .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved