LoginSignup
11
12

More than 5 years have passed since last update.

python2.7→python3.6切り替え(centos7)

Last updated at Posted at 2017-06-21

Centos7でのpython入れ替えメモ

# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

# yum install -y https://centos7.iuscommunity.org/ius-release.rpm
# yum search python36
# yum install -y python36u python36u-libs python36u-devel python36u-pip

シンボリックリンク張り替え
# ls -l /bin/py*
# ln -s /bin/python3.6 /bin/python3
# unlink /bin/python
# ln -s /bin/python3.6 /bin/python
# vim $(which pip)
1行目  #!/usr/bin/python2   → #!/usr/bin/python
# pip --version
pip 9.0.1 from /usr/lib/python3.6/site-packages (python 3.6)

awscli使っている場合

# vim $(which aws)
1行目  #!/usr/bin/python2   → #!/usr/bin/python

以下のようなエラーが出たら

# aws s3 ls
Traceback (most recent call last):
  File "/bin/aws", line 19, in <module>
    import awscli.clidriver
ModuleNotFoundError: No module named 'awscli'

installします

# sudo pip install awscli

追記

yumも動かなくなる。

# yum
  File "/bin/yum", line 30
    except KeyboardInterrupt, e:
                            ^
SyntaxError: invalid syntax

python3になるとprint命令文からprint()に変わっていたり、
例外のキャッチ構文が,(カンマ)からasに変わっていたりするため。
リンクを貼り直せば普通に使えるようになるけれど。。
うーん?どうしよう

11
12
1

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
11
12