1
1

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 5 years have passed since last update.

Windows proxy認証環境下(@含)でのpip

Last updated at Posted at 2019-03-14

proxy認証(@含)でのpip

  • Qiitaの記載記事も、ネットの記事もうまくいかない場合ためしてみてください。
  • Windowsの場合、環境変数に登録すれば問題は解決しますが、ここでは別の手法を提案します。

pipでエラー

bat
(venv) $ pip install request
Collecting request
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('
<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000001BF9A115668>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',)': /simple/request/

pip --proxyでエラー

bat
(venv) $ pip install request
Collecting request
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('
<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000001BF9A115668>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',)': /simple/request/

set proxy

bat
(venv) $ set set HTTP_PROXY=http://[username]%40[userdomain]:[password]@[proxy]:[port]
(venv) $ set set HTTPS_PROXY=http://[username]%40[userdomain]:[password]@[proxy]:[port]
(venv) $ pip install request
Collecting request
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('
<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000001BF9A115668>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',)': /simple/request/

結論

  • 環境変数に登録する
    • HTTP_PROXY=http://[username]%40[userdomain]:[password]@[proxy]:[port]
  • もしくは!set コマンドを使う
    • ただし「%%40」にする
      • set HTTP_PROXY=http://[username]%%40[userdomain]:[password]@[proxy]:[port]
bat
set HTTP_PROXY=http://[username]%%40[userdomain]:[password]@[proxy]:[port]
set HTTP_PROXY=http://[username]%%40[userdomain]:[password]@[proxy]:[port]
pip install request

pipをバッチにしておく

  • ppipというバッチを作り、Proxyを気にしないpipを準備します。
  • ppipはPATHに通してください
ppip.bat
@echo off

if "%1" equ "install" (
  goto proxy_install
)
if "%1" equ "show" (
  goto show
)

:show
pip freeze
goto end


:proxy_install
rem batの場合%%40
set HTTP_PROXY=http://[username]%%40[userdomain]:[password]@[proxy]:[port]
set HTTP_PROXY=http://[username]%%40[userdomain]:[password]@[proxy]:[port]
pip install %2
goto end


:end
python
ppip install request
1
1
1

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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?