2017-06-27 90 views
0

我想離線安裝python軟件包。爲此,我使用pip install --cache-dir在線收集它們,然後在下一次以相同的方式脫機時,期望pip將始終讀取緩存。從高速緩存pip安裝有時會失敗,當沒有網絡

第一次:在線(清空緩存,空的virtualenv):

~/tmp/venv$ LANG=C pip install --cache-dir /tmp/pipcache matplotlib 
Collecting matplotlib 
    Downloading matplotlib-2.0.2-cp27-cp27mu-manylinux1_x86_64.whl (14.5MB) 
    100% |################################| 14.5MB 99kB/s 
Collecting numpy>=1.7.1 (from matplotlib) 
    Downloading numpy-1.13.0-cp27-cp27mu-manylinux1_x86_64.whl (16.6MB) 
    100% |################################| 16.6MB 86kB/s 
Collecting cycler>=0.10 (from matplotlib) 
    Downloading cycler-0.10.0-py2.py3-none-any.whl 
Collecting python-dateutil (from matplotlib) 
    Downloading python_dateutil-2.6.0-py2.py3-none-any.whl (194kB) 
    100% |################################| 194kB 5.8MB/s 
Collecting functools32 (from matplotlib) 
    Downloading functools32-3.2.3-2.zip 
Collecting six>=1.10 (from matplotlib) 
    Downloading six-1.10.0-py2.py3-none-any.whl 
Collecting pytz (from matplotlib) 
    Downloading pytz-2017.2-py2.py3-none-any.whl (484kB) 
    100% |################################| 491kB 3.1MB/s 
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 (from matplotlib) 
    Downloading pyparsing-2.2.0-py2.py3-none-any.whl (56kB) 
    100% |################################| 61kB 8.8MB/s 
Collecting subprocess32 (from matplotlib) 
    Downloading subprocess32-3.2.7.tar.gz (54kB) 
    100% |################################| 61kB 8.4MB/s 
Building wheels for collected packages: functools32, subprocess32 
    Running setup.py bdist_wheel for functools32 ... done 
    Stored in directory: /tmp/pipcache/wheels/3c/d0/09/cd78d0ff4d6cfecfbd730782a7815a4571cd2cd4d2ed6e69d9 
    Running setup.py bdist_wheel for subprocess32 ... done 
    Stored in directory: /tmp/pipcache/wheels/7d/4c/a4/ce9ceb463dae01f4b95e670abd9afc8d65a45f38012f8030cc 
Successfully built functools32 subprocess32 
Installing collected packages: numpy, six, cycler, python-dateutil, functools32, pytz, pyparsing, subprocess32, matplotlib 
Successfully installed cycler-0.10.0 functools32-3.2.3.post2 matplotlib-2.0.2 numpy-1.13.0 pyparsing-2.2.0 python-dateutil-2.6.0 pytz-2017.2 six-1.10.0 subprocess32-3.2.7 

第二次:下線(重用緩存,重新創​​建空的virtualenv),一切都OK了:

~/tmp/venv$ LANG=C pip install --cache-dir /tmp/pipcache matplotlib 
Collecting matplotlib 
    Using cached matplotlib-2.0.2-cp27-cp27mu-manylinux1_x86_64.whl 
Collecting numpy>=1.7.1 (from matplotlib) 
    Using cached numpy-1.13.0-cp27-cp27mu-manylinux1_x86_64.whl 
Collecting cycler>=0.10 (from matplotlib) 
    Using cached cycler-0.10.0-py2.py3-none-any.whl 
Collecting python-dateutil (from matplotlib) 
    Using cached python_dateutil-2.6.0-py2.py3-none-any.whl 
Collecting functools32 (from matplotlib) 
Collecting six>=1.10 (from matplotlib) 
    Using cached six-1.10.0-py2.py3-none-any.whl 
Collecting pytz (from matplotlib) 
    Using cached pytz-2017.2-py2.py3-none-any.whl 
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 (from matplotlib) 
    Using cached pyparsing-2.2.0-py2.py3-none-any.whl 
Collecting subprocess32 (from matplotlib) 
Installing collected packages: numpy, six, cycler, python-dateutil, functools32, pytz, pyparsing, subprocess32, matplotlib 
Successfully installed cycler-0.10.0 functools32-3.2.3.post2 matplotlib-2.0.2 numpy-1.13.0 pyparsing-2.2.0 python-dateutil-2.6.0 pytz-2017.2 six-1.10.0 subprocess32-3.2.7 

的第三次:離線(重用緩存,重新創​​建虛擬virtualenv),一些錯誤:

~/tmp/venv$ LANG=C pip install --cache-dir /tmp/pipcache matplotlib 
Collecting matplotlib 
    Using cached matplotlib-2.0.2-cp27-cp27mu-manylinux1_x86_64.whl 
Collecting numpy>=1.7.1 (from matplotlib) 
    Using cached numpy-1.13.0-cp27-cp27mu-manylinux1_x86_64.whl 
Collecting cycler>=0.10 (from matplotlib) 
    Using cached cycler-0.10.0-py2.py3-none-any.whl 
Collecting python-dateutil (from matplotlib) 
    Using cached python_dateutil-2.6.0-py2.py3-none-any.whl 
Collecting functools32 (from matplotlib) 
Collecting six>=1.10 (from matplotlib) 
    Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f7abfbdbfd0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/six/ 
    Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f7abfbdb490>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/six/ 
    Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f7abfbdbf50>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/six/ 
    Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f7ac1068ed0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/six/ 
    Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f7ac1068910>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/six/ 
    Could not find a version that satisfies the requirement six>=1.10 (from matplotlib) (from versions:) 
No matching distribution found for six>=1.10 (from matplotlib) 

There ar e網絡錯誤:我不知道爲什麼,因爲所有包都在緩存中可用。另外,這些錯誤是隨機的:安裝六個或pytz軟件包時可能會發生。有時在發生上述情況時可能沒有任何錯誤。

如何解決此問題,以便我可以進行脫機安裝?

注:畫中畫和setuptools的是在其最新版本

+0

據https://stackoverflow.com/questions/4806448/how-do-i-install-from-a-local-cache- with-pip,因爲默認情況下打開了緩存,所以不需要--cache-dir選項。 –

回答

0

嘗試adding the --no-index parameter(也可能是--find-links太)。

編輯:使用pip downloadpip install -f似乎工作:

$ docker run -it python:3.6 bash 

[email protected]:/# cd tmp 
[email protected]:/tmp# ls 
[email protected]:/tmp# mkdir cache 
[email protected]:/tmp# pip download -d cache matplotlib 
Successfully downloaded matplotlib pytz numpy six pyparsing cycler python-dateutil 
[email protected]:/tmp# pip install --no-index matplotlib 
No matching distribution found for matplotlib 
[email protected]:/tmp# pip install --no-index matplotlib -f cache/ 
Collecting matplotlib 
Collecting cycler>=0.10 (from matplotlib) 
Collecting pyparsing!=2.0.0,!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 (from matplotlib) 
Collecting python-dateutil (from matplotlib) 
Collecting pytz (from matplotlib) 
Collecting numpy>=1.7.1 (from matplotlib) 
Collecting six>=1.10 (from matplotlib) 
Installing collected packages: six, cycler, pyparsing, python-dateutil, pytz, numpy, matplotlib 
Successfully installed cycler-0.10.0 matplotlib-2.0.2 numpy-1.13.0 pyparsing-2.2.0 python-dateutil-2.6.0 pytz-2017.2 six-1.10.0 
[email protected]:/tmp# 
+0

我嘗試了很多combinaisons,但是使用--no-index我有「找不到滿足matplotlib要求的版本」,而--find-links指向緩存我有相同的行爲:隨機錯誤。 – Eric

+0

@Eric:看我的編輯 - 似乎工作:) – AKX

+0

您是否在安裝時切斷網絡? – Eric