Home  >  Q&A  >  body text

How to configure the domestic pypi mirror source?

PyPI (Python Package Index) is a software repository for the Python programming language. Developers can find and install software developed and shared by the Python community through PyPI, and they can also upload their own developed libraries to PyPI.

So how to configure the domestic pypi mirror source

萌褚萌褚990 days ago1064

reply all(5)I'll reply

  • yntdx

    yntdx2021-11-11 09:08:12

    I use Xiaoniao Cloud Server. I used pip to install it directly. Since the default installation source of pip is located abroad, the speed is very slow and the link is often broken, so the expansion package cannot be installed normally. Later, the -i (long format: --index) parameter can be used to temporarily point the installation source to the domestic source. You can also permanently change the pip source by configuring the pip source configuration file. Permanently modify the Linux system. Under Linux, modify ~/.pip/pip.conf (If not, create a folder and file. Add "." to the folder to indicate a hidden folder) [global]index-url = http:/ /mirrors.aliyun.com/pypi/simple/[install]trusted-host=mirrors.aliyun.com Windows system Create the "pip" directory in the "C:\Users\your username\" directory, "pip" directory Create the "pip.ini" file (note: encoded in UTF-8 without BOM format). "pip.ini" file content: [global]index-url = http://mirrors.aliyun.com/pypi/simple/[install]trusted-host=mirrors.aliyun.com Use Notepad, notepad, etc. under the window When editing a file, if it is saved as UNICODE or UTF-8, two bytes "\xFF\xFE" and three bytes "\xEF\xBB\xBF" will be added to the beginning of the file respectively. That is: BOM. At this time, pip will report the error "ConfigParser.MissingSectionHeaderError: File contains no section headers." when reading the configuration file. At this time, use the following Python script to process pip.ini: import redef remove_BOM(config_path): content = open (config_path).read() content = re.sub(r"\xfe\xff","", content) content = re.sub(r"\xff\xfe","", content) content = re.sub (r"\xef\xbb\xbf","", content) open(config_path, 'w').write(content)if __name__ == '__main__': config_path = "C:\Users\Administrator\pip\pip .ini" # Change the path here to the path corresponding to your configuration file remove_BOM(config_path)

    reply
    0
  • hehahha

    hehahha2021-11-09 15:55:34

    Alibaba Cloud official mirror source:

    https://developer.aliyun.com/mirror/?utm_content=g_1000303593

    PyPI mirror source configuration method

    a. Find the following files

    ~/.pip/pip.conf

    b. Add or modify the above files:

    [global]
    index-url = https://mirrors.aliyun.com/pypi/simple/
    [install]
    trusted-host=mirrors.aliyun.com

    reply
    0
  • Cancelreply