How to solve the timeout problem when pip is used in Linux instances pip is one of the most popular Python package management tools. Many Alibaba Cloud users use pip to update system sources. Alibaba Cloud's pip source addresses are as follows: (Default) Public network: mirrors.aliyun.com Private network VPC intranet: mirrors.cloud.aliyuncs.com Classic network intranet: mirrors.aliyuncs.com Description of the phenomenon Pip requests for Linux instances occasionally time out or fail. Currently, the affected public images are: CentOS Debian Ubuntu SUSE OpenSUSE Aliyun Linux Cause Analysis The default access address for pip requests is mirrors.aliyun.com, and the instance accessing this address must be able to access the public network. When your instance is not assigned a public IP, a pip request timeout failure may occur. Workaround You can use any of the following methods to resolve the issue. Method 1 Assign a public IP address to your instance, that is, bind an elastic public IP address (EIP) to the instance. Prepaid instances can also reallocate public IP addresses through upgrading or downgrading. Method 2 If there is a delay in pip response, you can run the script fix_pypi.sh in the ECS instance and then retry the pip operation. Remote connection instance. Run wget http://image-offline.oss-cn-hangzhou.aliyuncs.com/fix/fix_pypi.sh to obtain the file. Run the script: VPC instance: Run bash fix_pypi.sh "mirrors.cloud.aliyuncs.com". Classic network instance: Run bash fix_pypi.sh "mirrors.aliyuncs.com". Retry the pip operation. The following is the script content of fix_pypi.sh: #!/bin/bash function config_pip() { pypi_source=$1 if [[ ! -f ~/.pydistutils.cfg ]]; then cat > ~/.pydistutils.cfg << EOF [easy_install] index-url=http://$pypi_source/pypi/simple/ EOF else sed -i "s#index-url.*#index-url=http://$pypi_source/pypi/simple/#" ~/.pydistutils.cfg fi if [[ ! -f ~/.pip/pip.conf ]]; then mkdir -p ~/.pip cat > ~/.pip/pip.conf << EOF [global] index-url=http://$pypi_source/pypi/simple/ [install] trusted-host=$pypi_source EOF else sed -i "s#index-url.*#index-url=http://$pypi_source/pypi/simple/#" ~/.pip/pip.conf sed -i "s#trusted-host.*#trusted-host=$pypi_source#" ~/.pip/pip.conf fi } config_pip $1 The above is all the content and knowledge points of this article. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
<<: How to create a MySQL database (de1) using commands
>>: Mini Program implements list countdown function
As a tester, you may often need to install some s...
1. dhtmlxTree dHTMLxTree is a feature-rich Tree M...
Table of contents 1.1Tinyint Type Description 1.2...
The idea of using token for login verification ...
Table of contents 1. Overview of MySQL Logical Ar...
In the previous article, we explained how nginx r...
Let's try out nginx's reverse proxy here....
This article example shares the specific code of ...
Preface I recently made a fireworks animation, wh...
vmware workstations starts the virtual machine er...
Table of contents 1. Introduction 1.1 Principle 1...
MAC installs mysql8.0, the specific contents are ...
1. left(name,4) intercepts the 4 characters on th...
A Textbox with Dropdown allows users to select an...
This article shares the specific code of vue echa...