【AWS】【RedHat 7系、8系】EC2 インスタンスへの pip インストール手順

公開日時:2019年01月20日 / 最終更新日時:2019年08月17日

RedHat 7系と RedHat 8系 の AWS EC2 インスタンスに pip をインストールする手順です。

pip をインストールすることで、Python のインストールが簡単になります。 

また、pip をインストールすることで「AWS CLI」のインストールも簡単にできるようになります。

 

 

pip をインストールする環境

対象の AWS EC2 インスタンスは「Red Hat Linux 7.6」です。

[root@redhat7 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.6 (Maipo)
[root@redhat7 ~]#

 

 

デフォルトで「easy_install」ツールがインストールされています。

[root@redhat7 ~]# easy_install --version
setuptools 0.9.8
[root@redhat7 ~]#

 

 

RedHat 8系への easy_install ツールインストール手順

RedHat 8系の場合は easy_install ツールがインストールされていないため、インストールが必要になります。

[root@AWSCLI ~]# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.0 (Ootpa)

 

 

RedHat 8系の場合は、Python の設定を含めこちらの記事を参考にしてください。

 

【RedHat 8】Python3.6 および pip3.6 のインストール手順【AWS EC2 インスタンス】

 

 

 

RedHat 8系には「easy_install」コマンドがインストールされていません。

[root@AWSCLI ~]# easy_install --version
-bash: easy_install: command not found

 

 

 

setuptools のパッケージを確認します。

今回は Python3 系なので、「python3-setuptools」をインストールします。

[root@AWSCLI ~]# yum search setuptools 
Last metadata expiration check: 0:28:36 ago on Sun 26 May 2019 12:40:37 AM UTC. 
======================================= Name Matched: setuptools ======================================= 
python3-setuptools.noarch : Easily build and distribute Python 3 packages 
python2-setuptools.noarch : Easily build and distribute Python packages 
python3-setuptools.noarch : Easily build and distribute Python 3 packages 
python2-setuptools_scm.noarch : Blessed package to manage your versions by scm tags 
platform-python-setuptools.noarch : Easily build and distribute Python 3 packages 
platform-python-setuptools.noarch : Easily build and distribute Python 3 packages 
[root@AWSCLI ~]#

 

 

 

【エラー】Error: Failed to synchronize cache for repo 'rhui-client-config-server-8'

一般アカウントの場合は権限が足りなくて以下のようなエラーが出力されるので root アカウントにスイッチします。

[ec2-user@AWSCLI  ~]$ yum search setuptools 
Extra Packages for Enterprise Linux 8 - x86_64                          172 kB/s | 430 kB     00:02 
Red Hat Update Infrastructure 3 Client Configuration Server 8           0.0  B/s |   0  B     00:01 
Error: Failed to synchronize cache for repo 'rhui-client-config-server-8' 
[ec2-user@AWSCLI  ~]$

 

 

 

 

 

「python3-setuptools」のインストールを実行しましたが、既にインストールされているようです。

[root@AWSCLI ~]# yum install python3-setuptools 
Last metadata expiration check: 0:00:06 ago on Sun 26 May 2019 01:14:01 AM UTC. 
Package python3-setuptools-39.2.0-4.el8.noarch is already installed. 
Dependencies resolved. 
Nothing to do. 
Complete! 
[root@AWSCLI ~]#

 

 

 

確かにコマンドを確認したら既に Python 3系の easy_install がインストールされていました。

[root@AWSCLI ~]# easy_install-3
easy_install-3   easy_install-3.6
[root@AWSCLI ~]#

 

 

「easy_install-3」「easy_install-3.6」ファイルのパスを確認します。

※alternatives コマンドで Python の標準を Python 3系にしましたが、その影響で以下のようになっています。

[root@AWSCLI ~]# cd /usr/bin/ 
[root@AWSCLI bin]# ls -l | grep easy_install 
lrwxrwxrwx. 1 root root      32 May 12 14:44 easy_install-3 -> /etc/alternatives/easy_install-3 
-rwxr-xr-x. 1 root root     246 Oct 25  2018 easy_install-3.6 
[root@AWSCLI bin]#

 

 

 

 

pip のインストール

easy_install コマンドで pip をインストールします。

warning が大量に出ていますが、一応問題なくインストールできているようです。

[root@redhat7 ~]# easy_install pip 
Searching for pip 
Reading https://pypi.python.org/simple/pip/ 
Best match: pip 18.1 
Downloading https://files.pythonhosted.org/packages/45/ae/8a0ad77defb7cc903f09e551d88b443304a9bd6e6f124e75c0fbbf6de8f7/pip-18.1.tar.gz#sha256=c0a292bd977ef590379a3f05d7b7f65135487b67470f6281289a94e015650ea1 
Processing pip-18.1.tar.gz 
Writing /tmp/easy_install-VYfyYH/pip-18.1/setup.cfg 
Running pip-18.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-VYfyYH/pip-18.1/egg-dist-tmp-QW1bAE 
/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires' 
  warnings.warn(msg) 
warning: no files found matching 'docs/docutils.conf' 
warning: no previously-included files found matching '.coveragerc' 
warning: no previously-included files found matching '.mailmap' 
warning: no previously-included files found matching '.travis.yml' 
warning: no previously-included files found matching 'tox.ini' 
warning: no previously-included files found matching 'appveyor.yml' 
warning: no files found matching 'Makefile' under directory 'docs' 
warning: no files found matching '*.bat' under directory 'docs' 
warning: no previously-included files found matching 'src/pip/_vendor/six' 
warning: no previously-included files found matching 'src/pip/_vendor/six/moves' 
warning: no previously-included files matching '*.pyi' found under directory 'src/pip/_vendor' 
no previously-included directories found matching '.github' 
no previously-included directories found matching 'docs/build' 
no previously-included directories found matching 'news' 
no previously-included directories found matching 'tasks' 
no previously-included directories found matching 'tests' 
no previously-included directories found matching 'tools' 
Adding pip 18.1 to easy-install.pth file 
Installing pip script to /usr/bin 
Installing pip2.7 script to /usr/bin 
Installing pip2 script to /usr/bin 
 
Installed /usr/lib/python2.7/site-packages/pip-18.1-py2.7.egg 
Processing dependencies for pip 
Finished processing dependencies for pip 
[root@redhat7 ~]#

 

pip のバージョンは「18.1」です。

[root@redhat7 ~]# pip --version
pip 18.1 from /usr/lib/python2.7/site-packages/pip-18.1-py2.7.egg/pip (python 2.7)
[root@redhat7 ~]#

 

pip のパスです。

[root@redhat7 ~]# which pip
/bin/pip
[root@redhat7 ~]#

 

 

pip のアップグレード手順です。

[root@redhat7 ~]# easy_install --upgrade pip 
Searching for pip 
Reading https://pypi.python.org/simple/pip/ 
Best match: pip 18.1 
Processing pip-18.1-py2.7.egg 
pip 18.1 is already the active version in easy-install.pth 
Installing pip script to /usr/bin 
Installing pip2.7 script to /usr/bin 
Installing pip2 script to /usr/bin 
 
Using /usr/lib/python2.7/site-packages/pip-18.1-py2.7.egg 
Processing dependencies for pip 
Finished processing dependencies for pip 
[root@redhat7 ~]#

 

 

 

 

Posted by 100%レンタルサーバーを使いこなすサイト管理人

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

AlphaOmega Captcha Medica  –  What Do You See?
     
 

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

Secured By miniOrange