LoginSignup
4
5

More than 5 years have passed since last update.

proxy下でのpipコマンドの実行(備忘録)

Posted at

proxy環境のもとでpipコマンド(例えばinstall, search等)を実行しようとしてもエラーが出て実行できない。

既に、いろいろな方が同様の記事を書いているが、そのどれを試してもうまく行かなかったので、私の環境下(iMac OSX Yosemite Python3.6)で動作した方法をメモ。

pipのコマンドには--proxy=user:pass@proxy:portでプロキシ設定を行うことができるが、これは動作しなかった。

つぎに、環境変数に直接設定してやる方法

export http_proxy="user:pass@proxy:port"
export https_proxy=$http_proxy
export ALL_proxy=$http_proxy

を実行してもうまく動作しなかった。

しかし、同様の作業を別のPC(MacbookPro OSX Marvericks Python3.5)で試すと、動作した。

ここでおかしいと思い、Python上でうまくproxyが通っているか、確認した。

commandlineでPythonを呼び出して
import urllib.request
urllib.request.getproxies()

上記のコマンドを実行して確認すると、何故か

{'http':'"user:pass@proxy:port"','https':'"user:pass@proxy:port"','all':'"user:pass@proxy:port"'}

となっていた。

ここでexport http_proxy="user:pass@proxy:port"のダブルクォーテーションを外し、export http_proxy=user:pass@proxy:portとすると、pipのコマンドが正常に動作した。

後日同様の作業を実行すると、ダブルクォーテーション込でも正常に動作した。
なぜ?

4
5
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
4
5