LoginSignup
69
87

More than 5 years have passed since last update.

CentOS7にPython3をインストール

Last updated at Posted at 2017-09-10

Pythonの最新版は3.xなのですが、2と互換性がないとかで、2.xもよく使われています。
CentOS7に標準で含まれているpythonも2.xです。
どうせなら3.xを使いたいということで、CentOS7にPython3をインストールしました。

Python3のインストール

IUSというリポジトリを追加します。

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

現時点での最新の3.x系は3.6なので3.6をインストールします。

$ yum search python36
$ sudo yum install python36u python36u-libs python36u-devel python36u-pip

検索して必要そうなパッケージをインストールします。

確認

helloworld.py
print("Hello World!")
$ python3.6 helloworld.py
Hello World!

前述の通り、CentOS7にはpythonが含まれていて、これを置き換えるつもりはないので、実行時は「python3.6」というコマンドで実行しています。

$ python --version
Python 2.7.5
$ python3.6 --version
Python 3.6.2

終わりです。

参考

69
87
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
69
87