ウェブサイト検索

RHEL 7 LinuxにおけるPythonパッケージツールPIPのインストール


RHEL 7 LinuxにPIPというPythonパッケージツールをインストールするためには、まず唯一の前提条件であるsetuptoolsパッケージをインストールする必要があります。さもなければ、以下のエラーメッセージが表示されます:


Downloading/unpacking pip
  Cannot fetch index base URL https://pypi.python.org/simple/
  Could not find any downloads that satisfy the requirement pip
Cleaning up...
No distributions at all found for pip
Storing debug log for failure in /root/.pip/pip.log

この理由から、まず setuptools をインストールします:


[root@rhel7 ~]# wget https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.tar.gz --no-check-certificate
[root@rhel7 ~]# tar xzf setuptools-7.0.tar.gz
[root@rhel7 ~]# cd setuptools-7.0
[root@rhel7 ~]# python setup.py install
...
Installed /usr/lib/python2.7/site-packages/setuptools-7.0-py2.7.egg
Processing dependencies for setuptools==7.0
Finished processing dependencies for setuptools==7.0

一度 setuptools パッケージがインストールされると、実際の PIP インストールに進むことができます。ここでは、python がすでに Redhat 7 Linux システムにインストールされていると仮定しています。


[root@rhel7 ~]# wget https://bootstrap.pypa.io/get-pip.py
[root@rhel7 ~]# python get-pip.py
Downloading/unpacking pip
  Downloading pip-1.5.6-py2.py3-none-any.whl (1.0MB): 1.0MB downloaded
Installing collected packages: pip
Successfully installed pip
Cleaning up...

全て完了しました。PIPのバージョンを確認して私たちの行動を確認しましょう:


[root@rhel7 ~]# pip --version
pip 1.5.6 from /usr/lib/python2.7/site-packages (python 2.7)

{loadposition python-tutorial-toc}

関連記事: