Python learning notes-use pip to install the module, pythonpip

Source: Internet
Author: User

Python learning notes-use pip to install the module, pythonpip

We often need to install various modules when using Python, while pip is a very powerful module Installation tool. Similar to linux Yum, It can automatically resolve dependencies when installing modules. The following is a summary:

 

1. Install pip:

Pip is automatically installed when python is installed.

 

Ii. pip:

1. Upgrade pip

    Python-m pip install -- upgrade pip

2. Installation Module

    Pip install gevent# Install a specified Module

    Pip install-r requirements.txt# Install the list of modules defined in the requirements.txt File

 

3. Change pip Source

Pip when installing third-party modules, by default from the Python official module library: https://pypi.python.org download, but because often blocked by the firewall or download speed is slow, so you need to replace the domestic Image

 

There are many available sources on the Internet, such

Douban: http://pypi.douban.com/simple/
Tsinghua https://pypi.tuna.tsinghua.edu.cn/simple

Recently used more and more handy is the pip source of Tsinghua University, it is the official pypi image, every 5 minutes synchronization, address for https://pypi.tuna.tsinghua.edu.cn/simple

1. Temporary use:

You can add the parameter-I https://pypi.tuna.tsinghua.edu.cn/simple when using pip

For example: pip install-I https://pypi.tuna.tsinghua.edu.cn/simple gevent, this will install the gevent library from the image on Tsinghua side.

2,
Permanent modification, once and for all:


In Linux, modify ~ /. Pip/pip. conf (create one if there is no one), modify index-url to tuna, the content is as follows:


[Global]
Index-url = https://pypi.tuna.tsinghua.edu.cn/simple

In Windows, create a pip directory in the user directory, for example, C: \ Users \ xx \ pip. Create the pip. ini file. The content is as follows:

[Global]
Index-url = https://pypi.tuna.tsinghua.edu.cn/simple

    

 

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.