A Simple Guide to Change Python Pip Mirror URL – Python Tutorial

By | January 18, 2020

The default source url of python pip is:https://files.pythonhosted.org/. This site may be very slow and may cause you to fail to install python packages. In this tutorial, we will introduce you how to change the mirror url of python pip.

If you are using pip to install python packages and get timeout error, you can read:

Best Practice to Set Python Pip Install Timeout and Retry Times for Beginners – Python Tutorial

Meanwhile, we can change the default mirror url of python pip to a fast site, such as: https://mirrors.aliyun.com/pypi/simple/

How to change pip mirror url?

You can do as follow:

Update your pip version

You can update your python pip version by this comand.

pip install pip -U

If you get timeout error, you can use your new mirror url to update.

pip install -i https://mirrors.aliyun.com/pypi/simple/ pip -U

After you have updated your pip version, you may get an error: ImportError: cannot import name main. You can read this tutorial to fix it.

Fix Python Pip ImportError: cannot import name main – Python Tutorial

Change the mirror url of pip

You can use pip command below to change.

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

Then the default mirror url of python pip is changed.

pip set mirror url

Open a new terminal to run python pip

You should open a new terminal to run pip command, then the new mirror url will work.

Leave a Reply

Your email address will not be published. Required fields are marked *