Proxy配下でpip
を使用した時に発生したエラーの回避策を書いておきます。
環境情報
- Mac OSX 10.11.3(15D21)
- python 2.7.11
- pip 8.1.2
発生した問題
$ sudo pip install virtualenv --proxy http://[user]:[password]@[server]:[port] -vvv The directory '/Users/User/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/Users/User/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Collecting virtualenv 1 location(s) to search for versions of virtualenv: * https://pypi.python.org/simple/virtualenv/ Getting page https://pypi.python.org/simple/virtualenv/ Looking up "https://pypi.python.org/simple/virtualenv/" in the cache No cache entry available Starting new HTTPS connection (1): pypi.python.org Incremented Retry for (url='/simple/virtualenv/'): Retry(total=4, connect=None, read=None, redirect=None) Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x10a623a10>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))': /simple/virtualenv/
pipでproxy設定をするときは--proxy
をつけておけば良いと公式ドキュメントにも書かれていたのですが、どうも自分の環境だとうまくいかず-vvv
オプションをつけて確認してみました。
すると、こんなエラーが出てきてきました。
Collecting virtualenv 1 location(s) to search for versions of virtualenv: * https://pypi.python.org/simple/virtualenv/ Getting page https://pypi.python.org/simple/virtualenv/ Looking up "https://pypi.python.org/simple/virtualenv/" in the cache No cache entry available Starting new HTTPS connection (1): pypi.python.org Incremented Retry for (url='/simple/virtualenv/'): Retry(total=4, connect=None, read=None, redirect=None)
よくよーく注目するとアクセスしに行ってるページがhttps
では…?
もしかして--proxy
ってhttp_proxyと同じでhttp向け通信しかproxy経由にしない?
そんなバカな・・・と思いながらも試してみます。
$ sudo https_proxy=http://[user]:[password]@[server]:[port] pip install virtualenv The directory '/Users/User/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/Users/User/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Collecting virtualenv Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB) 100% |████████████████████████████████| 1.8MB 605kB/s Installing collected packages: virtualenv Successfully installed virtualenv You are using pip version 8.1.2, however version 9.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
できた・・・
え、そういうことなのか。