CentOS7 に Python3 インストール

サーバではまだPython2が主流だと思うので、共存させる形でPython3をインストールします。

IUS Community Projectのリポジトリを入れる。

# yum install -y https://centos7.iuscommunity.org/ius-release.rpm

インストール可能なPythonを確認する。

# yum search python

上記だと多すぎるので最新のPython3.6に絞って確認してみる。

# yum search python36
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * ius: mirrors.tongji.edu.cn
 * updates: ftp.iij.ad.jp
============================================================================================================================ N/S matched: python36 =============================================================================================================================
python36u-debuginfo.x86_64 : Debug information for package python36u
python36u-lxml-debuginfo.x86_64 : Debug information for package python36u-lxml
python36u-mod_wsgi-debuginfo.x86_64 : Debug information for package python36u-mod_wsgi
python36u-psycopg2-debuginfo.x86_64 : Debug information for package python36u-psycopg2
python36u-setproctitle-debuginfo.x86_64 : Debug information for package python36u-setproctitle
python36u-test.x86_64 : The self-test suite for the main python36u package
uwsgi-plugin-python36u-debuginfo.x86_64 : Debug information for package uwsgi-plugin-python36u
python36u.x86_64 : Interpreter of the Python programming language
python36u-debug.x86_64 : Debug version of the Python runtime
python36u-devel.x86_64 : Libraries and header files needed for Python development
python36u-gunicorn.noarch : Python WSGI application server
python36u-libs.x86_64 : Python runtime libraries
python36u-lxml.x86_64 : XML processing library combining libxml2/libxslt with the ElementTree API
python36u-mod_wsgi.x86_64 : A WSGI interface for Python web applications in Apache
python36u-pip.noarch : A tool for installing and managing Python packages
python36u-psycopg2.x86_64 : A PostgreSQL database adapter for Python
python36u-redis.noarch : Python interface to the Redis key-value store
python36u-setproctitle.x86_64 : Python module to customize a process title
python36u-setuptools.noarch : Easily build and distribute Python packages
python36u-tkinter.x86_64 : A GUI toolkit for Python
python36u-tools.x86_64 : A collection of tools included with Python including 2to3 and idle
uwsgi-plugin-python36u.x86_64 : uWSGI - Plugin for Python support

Name and summary matches only, use "search all" for everything.

今回は以下のパッケージをインストール。

# yum install python36u python36u-devel python36u-libs python36u-pip

CentOS7デフォルトのバージョン確認

# python -V
Python 2.7.5

インストールしたPython3.6のバージョン確認

# python3.6 -V
Python 3.6.4

Python3.xをpython3で実行できるようにシンボリックリンクを作成

# which python3.6
/bin/python3.6

# cd /bin/

# ln -s /bin/python3.6 python3

# which python3
/bin/python3

 

 

スポンサードリンク