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

Detailed explanation of Python switching PIP image source (installation source)

編輯:Python
Preface :

I'm learning python When , use pip Download some libraries , Sometimes very slow , It was on the verge of collapse . Because the default pip It's using Python Official source , But because foreign official sources are often blocked , Make it unusable , We can use domestic Python Mirror source , So as to solve Python The trouble of not installing the library .

Common domestic image sources
 http://pypi.douban.com/simple/ douban
http://mirrors.aliyun.com/pypi/simple/ Ali
http://pypi.hustunique.com/simple/ Huazhong University of technology
http://pypi.sdutlinux.org/simple/ Shandong University of technology
http://pypi.mirrors.ustc.edu.cn/simple/ University of science and technology of China
Method 1 :Windows Replace the image source permanently
  1. stay windows Enter... In the file manager “ %APPDATA% ”, As shown in the figure below :
  2. It will be located in a new directory (“C:\Users\Administrator\AppData\Roaming\pip\pip.ini”),Administrator For your user name , Create a new pip Folder , Then create a new one in the matching folder pip.ini file , As shown in the figure below :
  3. In the new pip.ini Enter the following in the file , Then save .
    Be careful :" index-url " The content of is the path of the image source , Replaceable
    [global]
    timeout = 6000
    index-url = http://pypi.douban.com/simple
    trusted-host = pypi.douban.com
    
    Here's the picture :
Method 2 :LInux Replace the image source permanently
  1. Need modification ~/ .pip/pip.conf ( Create a )
    cd ~
    mkdir -p .pip
    nano pip.conf # perhaps vi pip.con
    
  2. stay pip.conf In profile , Add configuration content , Just modify Li's default software source , The configuration is as follows :
    [global]
    timeout = 6000
    index-url = http://pypi.douban.com/simple
    trusted-host = pypi.douban.com
    
Method 3 : Temporarily install from the image source

pip Use when installing files : pip install < Package name > –trusted-host pypi.douban.com

such as : pip install pyquery –trusted-host pypi.douban.com

  1. To install django For example :
    pip install -i https://pypi.doubanio.com/simple/ Django
    pip install -i https://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com Djang
    
    notes :
    -i https://pypi.doubanio.com/simple/ ------ Indicates the use of watercress (-i == --index-url)
    --trusted-host pypi.doubanio.com -------- Indicates adding trust
    

Articles you may be interested in

  1. PyCharm-Professional( pro )2019 The latest perfect crack , Permanently activate
  2. python in break and continue Explain in detail the usage and differences of
  3. Python And Hello World Conditional output instance of

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