Use a domestic image source to accelerate the installation of Python PyPI packages

Source: Internet
Author: User

PIPY Domestic Mirror currently has:

http://pypi.douban.com/Watercress

http://pypi.hustunique.com/Huazhong University of Technology

http://pypi.sdutlinux.org/Shandong University of Technology

http://pypi.mirrors.ustc.edu.cn/China University of Science and Technology

This is a convenient way to install the PIP online, but it's a terrible thing to do when the network is unstable. The use of domestic mirrors is relatively good,

If you want to specify the source manually, you can specify the source by following the PIP with-I, such as installing the web.py frame with the source of the watercress:

Pip Install Web.py-i http://pypi.douban.com/simple

Note that there is a/simple directory behind!!!

To be formulated as a default, you need to create or modify a configuration file (Linux files in ~/.pip/pip.conf,windows in%homepath%\pip\pip.ini), and modify the contents to:

Code

[Global]

Index-url = Http://pypi.douban.com/simple

This will call the mirror by default when it is installed using PIP.

For more configuration parameters see: http://www.pip-installer.org/en/latest/configuration.html

Configurationconfig file

PIP allows the set all command line option defaults in a standard INI style config file.

The names and locations of the configuration files vary slightly across platforms.

    • On Unix and Mac OS X The configuration file is: $HOME/.pip/pip.conf
    • On Windows, the configuration file is: %home%\pip\pip.ini

You can set a custom path location for the config file using the environment variable pip_config_file.

The names of the settings is derived from the long command line option, e.g. if you want to use a different package index (--index-url) and set the HTTP timeout (--default-timeout) to seconds your config file would look Li Ke this:

[Global]   http://download.zope.org/ppix 

Each subcommand can is configured optionally in its own sections so, every global setting with the same name would be OV Erridden; e.g. decreasing the timeout to ten seconds when running the freeze(freezing Requirements) comman D and using seconds for all other commands are possible with:

[Global]   [Freeze]  

Boolean options like --ignore-installed or --no-dependencies can is set like this:

[Install]   trueYes 

Appending options like --find-links can is written on multiple lines:

[Global]  =    http://download.example.com[Install]= http://mirror1.example.com http ://mirror2.example.com     
Environment Variables

Pip ' s command line options can is set with environment variables using the formatpip_<upper_long_name> . Dashes (-) has to replaced with underscores (_).

For example, to set the default timeout:

Export pip_default_timeout=60

The same as passing the option to pip directly:

--Default-Timeout=[... ]

To set options The can is set multiple times on the command line, just add spaces in between values. For example:

Export pip_find_links= "Http://mirror1.example.com http://mirror2.example.com"

is the same as calling:

Pip Install--find-links=http://mirror1.example.com--find-links=http://mirror2.example.com
Config Precedence

Command Line Options has precedence over environment variables, which has precedence over the config file.

Within the config file, command specific sections has precedence over the global section.

Examples:

    • --host=foo overrides Pip_host=foo
    • Pip_host=foo overrides a config file with [global] HOST = foo
    • A command Specific section in the config file [<command>] host = bar ove Rrides the option with same name in the [global] config file section
Command completion

Pip comes with the Support-command line completion in bash and zsh.

To setup for bash:

$ pip Completion--bash >> ~/.profile

To setup for zsh:

$ pip Completion--zsh >> ~/.zprofile

Alternatively, can use the result of the completion command directly with the Eval function of your shell, e.g . By adding the following to your startup file:

Eval "' Pip completion--bash '"
Next Previous


Window needs to be modified:

%python_home%\lib\site-packages\pip\cmdoptions.py

Java code
    1. Index_url = Optionmaker (
    2. '-I ', '--index-url ', ' --pypi-url ',
    3. dest=' Index_url ',
    4. metavar=' URL ',
    5. #default=' https://pypi.python.org/simple/',
    6. default=' http://mirrors.bistu.edu.cn/pypi/',
    7. help=' Base URL of the Python package Index (default%default).

%python_home%\lib\site-packages\pip\commands\search.py

Java code
  1. Class Searchcommand (Command):
  2. "" Search for PyPI packages whose name or summary contains <query>. " ""  
  3. Name = ' Search '
  4. Usage = "" "
  5. %prog [Options] <query> "" "
  6. Summary = ' Search PyPI for packages '.
  7. def __init__ (self, *args, **kw):
  8. Super (Searchcommand, self). __init__ (*args, **kw)
  9. Self.cmd_opts.add_option (
  10. '--index ',
  11. dest=' index ',
  12. metavar=' URL ',
  13. #default=' Https://pypi.python.org/pypi ',
  14. default=' http://mirrors.bistu.edu.cn/pypi/',
  15. help=' Base URL of Python package Index (default%default) ')
  16. Self.parser.insert_option_group (0, self.cmd_opts)

[Linux] modifies the Easy_install and PIP image addresses

Using Easy_install and Pip will make it very easy to install and manage Pyhthon modules, but if you are in the country, the speed of downloading from the official image is a very maddening thing, like modifying a apt-get or yum mirror address, Easy_ Install and Pip also need to modify the mirror address. There are two ways to modify the mirror address of Easy_install and Pip, which can be implemented separately using commands and configuration.

Method 1: Temporarily modify the command mode
Easy_install:

1
Easy_install-i http://e.pypi.python.org/simple Fabric

Pip:

1
Pip-i http://e.pypi.python.org/simple Install Fabric

Method 2: Configure How to Modify
Easy_install:
1. Open Pydistutils.cfg

1
VI ~/.pydistutils.cfg

2. Write the following:

12
[Easy_install]index_url = Http://e.pypi.python.org/simple

Pip:
1. Open pip.conf

1
VI ~/.pip/pip.conf

2. Write the following:

12
[Global]index-url = Http://e.pypi.python.org/simple

Faster domestic images, all from Tsinghua University, the server in Beijing. The server of the public network is the official mirror
Public network: Http://e.pypi.python.org/simple
Education Network: Http://pypi.tuna.tsinghua.edu.cn/simple

Use a domestic image source to accelerate the installation of Python PyPI packages

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.