Where does pip download .whl files?

后端 未结 2 869
没有蜡笔的小新
没有蜡笔的小新 2021-01-12 04:23

I\'d like to install a certain python package with pip but because of the proxy I am sitting behind pip cannot connect to the internet.

So my question is: Where does

2条回答
  •  轮回少年
    2021-01-12 05:01

    How to get an URL pip is using to download the file:

    • Get JSON from https://pypi.python.org/pypi/package_name/json
    • parse releases part, select the latest release
    • go through available files (usually there are more than one), taking your platform into account (e.g. x32 vs x64, Windows or Linux version, installed Python etc)
    • use url property

    E.g.:

    import requests
    package = requests.get("https://pypi.python.org/pypi/pandas/json").json()
    max_ver = max(package["releases"].keys())
    # ... check compatibility
    file = get_file_idx(package['releases'][max_ver])
    urllib.urlretrieve(file["url"])
    

提交回复
热议问题