Switching pip download Linux source

Foreword

pip install package-nameCommand from official sources (direct https://pypi.python.org/pypi ) is mounted, moving speed, when the installation package can be, -iplus pypi source address, the source address may be changed domestic pip mirror station address, once and for all, the speed has improved significantly

Configuration

1. psm

Source github Address: https://github.com/brandonxiang/psm

This article uses the virtual environment pyenv created, python version is 3.6.6, pip version 19.1.1, create a virtual environment with pyenv python tutorial can blog https://blog.csdn.net/qq_27114273/article/details/ 90,340,754 find, not repeat them, created after the completion of the command pyenv activate env-nameinto the virtual environment. The same can also be used in combination virtualenv virtualenvwrapper to create a virtual environment, designated as a python version of the system environment.

Linux use

The following operation needs to be performed outside the virtual Linux environment, choose a good mirror source entering the virtual environment

(env366)vic@hell:~$ pip install psm

If the system is equipped with both python2 and python3, want to install python3 environment, you need pip3 install psmto install

  1. The mirror source listed pip
(env366)vic@hell:~$ psm ls

psm support domestic mirroring as follows:

View the current mirror source

(env366) vic@hell:~$ psm show

Current source is douban
  1. Select the specified mirror source
(env366) vic@hell:~$ psm use douban

Source is changed to douban.
  1. Use pip Download Library
(env366) vic@hell:~$ pip install package-name

Windows use

installation

pip install psm

Likewise, you want to install python3 version, then use pip3 install psmto install

List all sources

python -m psm ls

Pypi replacement source

python -m psm use douban

Displays the current source

python -m psm show

2. modify the configuration file

Change the profile, the pip set as the default source, for example switching to open-source software mirror sites Tsinghua University, Tsinghua PyPI mirror image of the station sync once every 5 minutes. But Tsinghua TensorFlow updated more slowly.

Temporary use can use the command

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple package-name

Linux under modification

pip version> = 10.0.0

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

When the network is poor, using the mirror Tsinghua station to upgrade pip:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U

If you do not want to upgrade version of pip, pip mirror source can be switched by modifying the configuration file

Modify ~ / .pip / pip.conf file, add the following, there is no such file or directory to create a

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

Modify under Windows

  1. In the address bar of the file manager %APPDATA%will switch to the user directory path appdata
  2. pip directory to find the file in the folder, not to create a new folder for the pip, create a file pip.ini In this folder, the full path%APPDATA%/pip/pip.ini
  3. Add the following code in pip.ini
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn/simple

Mac under modification

  1. Pip switching to the path, the path is:

$HOME/Library/Application Support/pip/pip.conf

%HOME%For the user's home directory

  1. Without the above directory, create a file in the following directory pip.conf

$HOME/.config/pip/pip.conf

  1. Add the following code
[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn/simple

note

After adding the code modification profile, it may be wrong, to make use of encryption source https



Open source software reference mirror sites Tsinghua University, pypi mirroring Help: https://mirrors.tuna.tsinghua.edu.cn/help/pypi/

Guess you like

Origin blog.csdn.net/qq_27114273/article/details/90515380