====== easy_install、setuptools、pip - パッケージ管理 ====== ===== Linux & Mac 編(get-pip.pyの場合) ===== $ curl -O https://bootstrap.pypa.io/get-pip.py % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1558k 100 1558k 0 0 2221k 0 --:--:-- --:--:-- --:--:-- 2222k $ sudo python get-pip.py Collecting pip Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB) 100% |████████████████████████████████| 1.3MB 913kB/s Collecting setuptools Downloading setuptools-34.3.1-py2.py3-none-any.whl (389kB) 100% |████████████████████████████████| 399kB 2.1MB/s 〜省略〜 Installing collected packages: pip, six, appdirs, pyparsing, packaging, setuptools, wheel Successfully installed appdirs-1.4.3 packaging-16.8 pip-9.0.1 pyparsing-2.2.0 setuptools-34.3.1 six-1.10.0 wheel-0.29.0 $ pip --version pip 9.0.1 from /usr/lib/python2.7/site-packages (python 2.7) $ easy_install --help Global options: --verbose (-v) run verbosely (default) --quiet (-q) run quietly (turns verbosity off) 〜省略〜 ===== Linux & Mac 編(ez_setup.pyの場合) ===== - ez_setup.py をダウンロード。 $ curl -O https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 11432 100 11432 0 0 10295 0 0:00:01 0:00:01 --:--:-- 10299 - インストールする。 $ sudo python ez_setup.py Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-17.0.zip Extracting in /tmp/tmpbV8DKr Now working in /tmp/tmpbV8DKr/setuptools-17.0 Installing Setuptools running install running bdist_egg running egg_info ~省略~ Processing dependencies for setuptools==17.0 Finished processing dependencies for setuptools==17.0 - easy_install の動作確認をする。 $ easy_install --help Global options: --verbose (-v) run verbosely (default) --quiet (-q) run quietly (turns verbosity off) --dry-run (-n) don't actually do anything ~省略~ - pip のインストールを行う。 $ sudo easy_install pip Searching for pip Reading http://pypi.python.org/simple/pip/ Reading http://pip.openplans.org Reading http://www.pip-installer.org Best match: pip 1.1 Downloading http://pypi.python.org/packages/source/p/pip/pip-1.1.tar.gz#md5=62a9f08dd5dc69d76734568a6c040508 Processing pip-1.1.tar.gz Running pip-1.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-pX20FR/pip-1.1/egg-dist-tmp-3vL47N warning: no files found matching '*.html' under directory 'docs' warning: no previously-included files matching '*.txt' found under directory 'docs/_build' no previously-included directories found matching 'docs/_build/_sources' Adding pip 1.1 to easy-install.pth file Installing pip script to /Library/Frameworks/Python.framework/Versions/2.7/bin Installing pip-2.7 script to /Library/Frameworks/Python.framework/Versions/2.7/bin Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.1-py2.7.egg Processing dependencies for pip Finished processing dependencies for pip pip を更新する場合 $ sudo easy_install -U pip Searching for pip Reading http://pypi.python.org/simple/pip/ Reading http://www.pip-installer.org Reading http://pip.openplans.org Best match: pip 1.3.1 Downloading http://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz#md5=cbb27a191cebc58997c4da8513863153 Processing pip-1.3.1.tar.gz Writing /tmp/easy_install-AQnSHy/pip-1.3.1/setup.cfg Running pip-1.3.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-AQnSHy/pip-1.3.1/egg-dist-tmp-NQUNu3 warning: no files found matching '*.html' under directory 'docs' warning: no previously-included files matching '*.txt' found under directory 'docs/_build' no previously-included directories found matching 'docs/_build/_sources' Removing pip 1.2.1 from easy-install.pth file Adding pip 1.3.1 to easy-install.pth file Installing pip script to /usr/bin Installing pip-2.7 script to /usr/bin Installed /usr/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg Processing dependencies for pip Finished processing dependencies for pip - pip の動作確認をする。 $ pip --version pip 1.1 from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.1-py2.7.egg (python 2.7) ===== Linux編(yumの場合) =====  yumで導入する場合は、以下のコマンドで行うことができる。 $ su - パスワード: # yum install python-setuptools python-pip  python-pipで導入されるpipコマンドは /usr/bin/pip-python となるようである。 ===== ubuntu(apt-getの場合) ===== $ sudo apt-get install python-pip ===== Windows編 ===== - [[http://peak.telecommunity.com/|PEAK - The Python Enterprise Application Kit]]より[[http://peak.telecommunity.com/dist/ez_setup.py|ez_setup.py]]をダウンロードする。 - ダウンロードした ez_setup.py を実行してインストールを行う。 > python ez_setup.py Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg Processing setuptools-0.6c11-py2.7.egg Copying setuptools-0.6c11-py2.7.egg to c:\python27\lib\site-packages Adding setuptools 0.6c11 to easy-install.pth file Installing easy_install-script.py script to C:\Python27\Scripts Installing easy_install.exe script to C:\Python27\Scripts Installing easy_install.exe.manifest script to C:\Python27\Scripts Installing easy_install-2.7-script.py script to C:\Python27\Scripts Installing easy_install-2.7.exe script to C:\Python27\Scripts Installing easy_install-2.7.exe.manifest script to C:\Python27\Scripts Installed c:\python27\lib\site-packages\setuptools-0.6c11-py2.7.egg Processing dependencies for setuptools==0.6c11 Finished processing dependencies for setuptools==0.6c11 - easy_install の動作確認をする。 > easy_install --help Global options: --verbose (-v) run verbosely (default) --quiet (-q) run quietly (turns verbosity off) --dry-run (-n) don't actually do anything ~省略~ - pip のインストールを行う。 > easy_install pip Searching for pip Reading http://pypi.python.org/simple/pip/ Reading http://pip.openplans.org Reading http://www.pip-installer.org Best match: pip 1.1 Downloading http://pypi.python.org/packages/source/p/pip/pip-1.1.tar.gz#md5=62a9f08dd5 dc69d76734568a6c040508 Processing pip-1.1.tar.gz Running pip-1.1\setup.py -q bdist_egg --dist-dir c:\users\tomoyan\appdata\local\temp\ easy_install-oqpnzh\pip-1.1\egg-dist-tmp-9on5uw warning: no files found matching '*.html' under directory 'docs' warning: no previously-included files matching '*.txt' found under directory 'docs\_build' no previously-included directories found matching 'docs\_build\_sources' Adding pip 1.1 to easy-install.pth file Installing pip-script.py script to C:\Python27\Scripts Installing pip.exe script to C:\Python27\Scripts Installing pip.exe.manifest script to C:\Python27\Scripts Installing pip-2.7-script.py script to C:\Python27\Scripts Installing pip-2.7.exe script to C:\Python27\Scripts Installing pip-2.7.exe.manifest script to C:\Python27\Scripts Installed c:\python27\lib\site-packages\pip-1.1-py2.7.egg Processing dependencies for pip Finished processing dependencies for pip - pip の動作確認をする。 > pip --version pip 1.1 from c:\python27\lib\site-packages\pip-1.1-py2.7.egg (python 2.7) ===== easy_install でProxyサーバを利用する方法(Windows編) =====  easy_install が利用する urllib2 に Proxy の設定を教えるためには、環境変数 HTTP_PROXY を以下のように設定する。\\ set HTTP_PROXY=http://your-proxy.co.jp:8080  認証を必要とする Proxy を利用するためには、環境変数 HTTP_PROXY を以下のように設定する。\\ set HTTP_PROXY=http://user:pass@your-proxy.co.jp:8080 ===== NTLM認証Proxyサーバ(ntlmaps)を利用する方法(Windows編) =====  NTLM認証Proxyサーバを経由してインストールを行う場合は、以下の手順にて行う。 - [[http://ntlmaps.sourceforge.net/|NTLM Authorization Proxy Server]] より [[http://sourceforge.net/project/showfiles.php?group_id=69259&package_id=68110&release_id=303755|SourceForge Downloads Page]]へ行き、ntlmaps-x.x.x.zip ファイルをダウンロードする。 - ntlmaps-x.x.x.zip ファイルを任意の場所に解凍する。 - 付属の server.cfg を自分の環境に合わせて修正する。\\ server.cfg(修正点のみ列挙)\\ LISTEN_PORT:5865 -> 8080 PARENT_PROXY:your_parentproxy -> proxy.xxx.co.jp NT_DOMAIN:your_domain -> xxx.co.jp USER:username_to_use -> tomoyan PASSWORD:your_nt_password -> password - 付属の runserver.bat の python.exe のパスを修正する。\\ runserver.bat\\ @echo off "c:\program files\python\python.exe" main.py -> python main.py - runserver.bat をダブルクリックして実行する。\\ 実行結果(利用可能状態で待機中)\\ NTLM authorization Proxy Server v0.9.9 Copyright (C) 2001-2004 by Dmitry Rozmanov and others. Now listening at your-machine-name on port 8080 - easy_install が利用する urllib2 に Proxy の設定を教えるために環境変数 HTTP_PROXY を設定する。\\ set HTTP_PROXY=http://localhost:8080