2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Proxyに阻まれ、Pythonやpipで接続エラーになり、Retryされてしまう

Last updated at Posted at 2021-01-05

自社開発環境はproxyサーバを介してネットワーク接続しているため、
ことあるごとにネットワークエラーになる。

例えばpipを実行時に単純に実行すると以下のようにRetryingが繰り返されます。


C:\Users\thithi7110>pip install webdriver_manager
Collecting webdriver_manager
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/webdriver-manager/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/webdriver-manager/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/webdriver-manager/
Operation cancelled by user

そこで実行時に

--proxy=<プロキシサーバ名>:
をつけて実行してみます。
ここでは以下の設定で実施しています。
プロキシサーバ名:proxy.hoge.co.jp
proxyポート:8080

C:\Users\thithi7110>pip install webdriver_manager --proxy=proxy.hoge.co.jp:8080
Collecting webdriver_manager
  Downloading https://files.pythonhosted.org/packages/dd/3c/2e2d71aeb28ee73ecaf12b545542b082ca81c8c091bb05028c52c42696ce/webdriver_manager-2.4.0-py2.py3-none-any.whl
Collecting crayons (from webdriver_manager)
  Downloading https://files.pythonhosted.org/packages/5b/0d/e3fad4ca1de8e70e06444e7d777a5984261e1db98758b5be3e8296c03fe9/crayons-0.4.0-py2.py3-none-any.whl
Collecting requests (from webdriver_manager)

無事ダウンロードが始まりました。

pythonを実行する際には、以下のように、
http_proxyとhttps_proxyを設定したあとにpythoを実行すればうまくいきました。

set http_proxy=http://proxy.hoge.co.jp:8080
set https_proxy=https://proxy.hoge.co.jp:8080

hoge.bat
rem proxy設定
set http_proxy=http://proxy.hoge.co.jp:8080
set https_proxy=https://proxy.hoge.co.jp:8080
python "fugafuga.py"
2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?