Home > Backend Development > Python Tutorial > Use Tsinghua mirror to speed up the construction of Python library installation environment

Use Tsinghua mirror to speed up the construction of Python library installation environment

PHPz
Release: 2024-01-16 09:26:17
Original
654 people have browsed it

Use Tsinghua mirror to speed up the construction of Python library installation environment

Use Tsinghua mirror to quickly build a Python library installation environment

Introduction:
Python is a widely used programming language with a wealth of third-party libraries. When developing projects using Python, you often encounter situations where you need to install various libraries. However, due to limitations of the domestic network environment, sometimes the downloading speed of the library from PyPI (Python Package Index) will be very slow, or even impossible to connect. In this case, we can use the Tsinghua University mirror station to speed up the installation process of the Python library through the high-speed download provided by the mirror station.

Tsinghua University Mirror Station:
Tsinghua University Mirror Station is one of the mirror stations trusted by users in China. It is excellent in providing mirror services for Linux, open source software and other development resources. By using mirror sites, we can quickly obtain various domestic and foreign software resources.

Specific steps:
Below we will step by step introduce how to use the Tsinghua Mirror Station to quickly build a Python library installation environment.

Step 1: Configure the mirror source
First, we need to add the Tsinghua mirror station as our mirror source in the Python configuration file. Open the terminal and execute the following command to edit the configuration file:

$ vim ~/.pip/pip.conf
Copy after login

If there is no pip.conf file in the ~/.pip directory, you can create a new one directly. Add the following content to the pip.conf file:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
Copy after login

Save and exit.

Step 2: Install the Python library
Now we can use the pip command to install the Python library. For example, if we want to install the numpy library, we can execute the following command in the terminal:

$ pip install numpy
Copy after login

This will download and install the numpy library from the Tsinghua mirror station.

Step 3: Upgrade the installed libraries
If we have installed some Python libraries using other mirror sources or default sources before, we can use the following command to update to the Tsinghua Mirror Station:

$ pip install -U --force-reinstall --no-cache-dir 库名
Copy after login

Among them, Library name is the name of the installed library. In this way, we can ensure that the installed libraries come from the Tsinghua mirror station and get the latest version.

Summary:
By configuring the Tsinghua mirror source, we can install various libraries more quickly in Python development. In this way, we can more quickly set up the required Python library installation environment for our project development. At the same time, as a stable and reliable mirror station, Tsinghua Mirror Station can also ensure the security and stability of the libraries we download from it.

Reference materials:

  1. Tsinghua University’s long-term maintained open source software mirror station [https://mirrors.tuna.tsinghua.edu.cn/](https://mirrors. tuna.tsinghua.edu.cn/)
  2. Mirror Tsinghua University obtains the fastest pypi source [https://mirrors.tuna.tsinghua.edu.cn/help/pypi/](https://mirrors .tuna.tsinghua.edu.cn/help/pypi/)

The above is the detailed content of Use Tsinghua mirror to speed up the construction of Python library installation environment. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template