Skip to content

Instantly share code, notes, and snippets.

@Hansimov
Last active April 10, 2023 12:35
Show Gist options
  • Save Hansimov/39bce1628ff883e89edbc8fa0377d1ee to your computer and use it in GitHub Desktop.
Save Hansimov/39bce1628ff883e89edbc8fa0377d1ee to your computer and use it in GitHub Desktop.
Python pip install timeout

Method 1: Download *.whl to local and install manually

Run shell as Administrator:

python -m pip install <package-name>.whl

  • If this package has some dependencies, you also need to download and install these dependencies mannualy, which are also shown in the WARNING info as /simple/<dependency-package>/.
  • Do not use the --force-reinstall option, since this will make pip to fetch dependencies remotely, which is not suitable for this case.
  • It is possible to write a script to extract the dependencies from the WARNING info, and fetch the .whl automatically from pypi.org and install it.

Method 2: Add proxy

Check your windows env variable for HTTP_PROXY:

echo %HTTP_PROXY%

There might be some deprecated configurations, so you need to clear them first.

In Windows, add this to C:/Users/<username>/pip/pip.ini:

[global]
proxy = http://<server>:<port>

Method 3: Add index url

In Windows, add this to C:/Users/<username>/pip/pip.ini:

[global]
proxy = http://<server>:<port>
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn

In Linux, use following command to view pip.conf

pip config -v list

If no contents exist in the files above, create a new file and add above lines:

cd ~ && mkdir .pip && touch pip.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment