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
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
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
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 库名
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:
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!