Python2.7とpython3.5はデフォルトでubuntu16.04にインストールされています
hanli@ubuntu:/usr/bin$ ls |grep python
dh_python2
dh_python3
python
python2
python2.7
python2.7-config
python2-config
python3
python3.5
python3.5m
python3m
python-config
x86_64-linux-gnu-python2.7-config
x86_64-linux-gnu-python-config
切り替える方法は?
hanli@ubuntu:/usr/bin$ python
Python2.7.12(default,Nov192016,06:48:10)
hanli@ubuntu:/usr/bin$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
update-alternatives: using /usr/bin/python2 to provide /usr/bin/python (python)in auto mode
hanli@ubuntu:/usr/bin$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
update-alternatives: using /usr/bin/python3 to provide /usr/bin/python (python)in auto mode
hanli@ubuntu:/usr/bin$ python
Python3.5.2(default,Nov172016,17:05:23)
hanli@ubuntu:/usr/bin$ sudo update-alternatives --config python
There are 2 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/python3 150 auto mode
1 /usr/bin/python2 100 manual mode
2 /usr/bin/python3 150 manual mode
Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/python2 to provide /usr/bin/python (python) in manual mode
# 番号の前*記号は現在のバージョンを示します。1を入力して2に切り替えます.7.次のように再度確認します
hanli@ubuntu:/usr/bin$ sudo update-alternatives --config python
There are 2 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3 150 auto mode
* 1 /usr/bin/python2 100 manual mode
2 /usr/bin/python3 150 manual mode
Press <enter> to keep the current choice[*], or type selection number:
Recommended Posts