6
7

More than 3 years have passed since last update.

pip installでproxyにインストールが阻まれる

Last updated at Posted at 2020-04-30

機械学習を触ってみようということで、環境のセットアップしています。
目標とする構成は、以下の通り。

  • OS:Windows 10
  • Python:3.7.3
  • Anaconda:4.6.11
  • Jupyter Notebook:5.7.8
  • TensorFlow:1.13.1
  • Keras:2.2.4

Anacondaをインストールし、いざAnaconda Powershell Promptからインストールを実行したところ、tensorflowのインストールを実行したところ、Time outになってしまいました。

(base) PS C:\Windows\system32> pip install tensorflow==1.13.1
Collecting tensorflow==1.13.1
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x0000028CF4E8E860>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/tensorflow/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x0000028CF4E8E898>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/tensorflow/
...

解決方法

1. 単純にproxyの設定漏れ

.condarcの末尾に、下記の内容を追記します。
.condarcはデフォルトで、C:¥Users¥ユーザー名¥にあるはず。

proxy_servers:
    http: http://<user>:<password>@<proxy_host>:<proxy_port>/
    https: http://<user>:<password>@<proxy_host>:<proxy_port>/

残念ながら解消せず。

2. pipのproxyオプションで指定

pip proxyなどでググると・・・(以下略
ということで、やってみました

 pip install tensorflow==1.13.1 --proxy http://<user>:<password>@<proxy_host>:<proxy_port>

これでインストールできました!

反省

Proxyと言われると、反射的に環境変数に設定することが多く、以下のように指定しててハマってました。

pip install tensorflow==1.13.1 --proxy <user>:<password>@<proxy_host>:<proxy_port>

Exception:
<以下略>

pip._vendor.urllib3.exceptions.ProxySchemeUnknown: Not supported proxy scheme

思い込みって怖いですね。

6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7