Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

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に変わっていたりするため。
リンクを貼り直せば普通に使えるようになるけれど。。
うーん?どうしよう

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away