Use Tsinghua Source to accelerate Python package downloads, Pip settings for Windows operating systems

王林
Release: 2024-01-17 10:47:06
Original
971 people have browsed it

Use Tsinghua Source to accelerate Python package downloads, Pip settings for Windows operating systems

Under Windows system, use Pip to set up Tsinghua source and speed up the download of Python package

Python is a widely used high-level programming language with powerful functions and Rich ecosystem. When developing in Python, we often need to download various third-party libraries from the Python Package Index (PyPI for short). However, because the PyPI server is located abroad, the download speed is slow, especially in the domestic network environment. In order to solve this problem, we can use the mirror source of Tsinghua University to speed up the download of Python packages.

Tsinghua Source is a service provided by Tsinghua University’s open source software mirror station. It provides many open source software images including PyPI. It is synchronized with the official PyPI source and can obtain the latest software packages in real time. The following will introduce how to use Pip to set up Tsinghua Source under Windows systems to speed up the download of Python packages.

First, we need to open the command prompt window (cmd). In Windows systems, you can use the shortcut key Win R to open the run window, then enter cmd and press the Enter key to open the command prompt window.

Next, we need to use Pip to set up Tsinghua Source. Pip is Python's package management tool, used to install, uninstall and manage Python packages. We can use the following command to set the Tsinghua source:

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

After executing the above command, Pip will set the Tsinghua source as the default software source. In this way, when using Pip to download the Python package, it will be downloaded from the Tsinghua source, thus speeding up the download speed.

In order to verify whether the Tsinghua source is set up successfully, we can use the following command to view the current software source:

pip config list
Copy after login

After executing the above command, the information of the currently used software source will be displayed. If the displayed URL is https://pypi.tuna.tsinghua.edu.cn/simple, it means that Tsinghua Source has been set up successfully.

After setting up Tsinghua source, we can use Pip normally to install and update Python packages. For example, we can use the following command to install the requests third-party library:

pip install requests
Copy after login

After executing the above command, Pip will download and install the requests library from Tsinghua source. Since Tsinghua Source is located in China, the download speed will be significantly faster.

In addition to the above methods, we can also set up Tsinghua Source by modifying the Pip configuration file. Pip's configuration file is located in the .pip folder in the user directory. We only need to create a file named pip.ini under the folder and add the following content in the file:

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

After saving the file, Pip will use Tsinghua source as the default software source.

Summary:

Under Windows systems, using Pip to set up Tsinghua source can speed up the download of Python packages. We can set up Tsinghua Source through the command line or modifying the configuration file. By using Tsinghua Source, we can quickly download Python packages in China, thereby improving development efficiency. Hope this article is helpful to you!

The above is the detailed content of Use Tsinghua Source to accelerate Python package downloads, Pip settings for Windows operating systems. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!