Timeout resolution for pip operations in linux

  • 2020-12-07 04:39:09
  • OfStack

How do I solve the timeout problem of Linux instance pip operation

pip is currently one of the most popular Python installation package management tools, and many Alicloud users update their system sources via pip. The pip source addresses of Aliyun are as follows:

Public network: ES12en. aliyun. com

Proprietary network VPC Intranet: mirrors. cloud. aliyuncs. com

Classic network Intranet: ES24en.aliyuncs.com

The phenomenon of description

The pip instance of Linux has either timed out or failed. At present, the affected public images include:

CentOS

Debian

Ubuntu

SUSE

OpenSUSE

Aliyun Linux

Cause analysis,

The default access address requested by pip is ES56en.aliyun.com, and the instance accessing this address is required to access the public network. An pip request timeout failure occurs when your instance is not allocated public network IP.

The solution

You can use any of the following methods to solve the problem.

Method 1

Assign public network IP to your instance, that is, bind 1 flexible public network IP (EIP) to your instance. The prepaid instance can also be reallocated to the public network IP via elevating and matching.

Method 2

Once the pip response is delayed, you can run the script fix_pypi.sh in the ECS instance, and then try the pip operation again.

Remote connection instance.

Run wget http: / / image - offline oss - cn - hangzhou. aliyuncs. com/fix/fix_pypi sh access to files.

Run script:

VPC example: running bash fix_pypi. sh "mirrors. cloud. aliyuncs. com".

Classic network example: Run bash fix_ES117en.sh "mirrors.aliyuncs.com".

Retry the pip operation.

The following is the contents of the es127EN_ES128en.sh script:


#!/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 the full content of this article knowledge, thank you for the support of this site.


Related articles: