Ubuntu18.04系统默认Python3为默认版本

0 系统版本

1 查看Python的指向

wu@acer:~$ ls -l /usr/bin/ | grep python
-rwxr-xr-x 1 root root        1056 4月  16  2018 dh_python2
lrwxrwxrwx 1 root root          23 11月 12 22:31 pdb2.7 -> ../lib/python2.7/pdb.py
lrwxrwxrwx 1 root root          23 10月 22 19:32 pdb3.6 -> ../lib/python3.6/pdb.py
lrwxrwxrwx 1 root root          31 10月 25 19:11 py3versions -> ../share/python3/py3versions.py
lrwxrwxrwx 1 root root           9 4月  16  2018 python -> python2.7
lrwxrwxrwx 1 root root           9 4月  16  2018 python2 -> python2.7
-rwxr-xr-x 1 root root     3670448 11月 12 22:31 python2.7
lrwxrwxrwx 1 root root           9 10月 25 19:11 python3 -> python3.6
-rwxr-xr-x 2 root root     4522328 10月 22 19:32 python3.6
-rwxr-xr-x 2 root root     4522328 10月 22 19:32 python3.6m
lrwxrwxrwx 1 root root          10 10月 25 19:11 python3m -> python3.6m
-rwxr-xr-x 1 root root         152 11月 11  2017 python3-pbr
lrwxrwxrwx 1 root root          29 4月  16  2018 pyversions -> ../share/python/pyversions.py

可以看到python -> python2.7,所以要把它指向下面那个Python3.6

2 删除原来的软链接,建立新的链接

sudo rm /usr/bin/python
sudo ln -s /usr/bin/python3.6 /usr/bin/python

3 查看验证一下

wu@acer:~$ ls -l /usr/bin/ | grep python
-rwxr-xr-x 1 root root        1056 4月  16  2018 dh_python2
lrwxrwxrwx 1 root root          23 11月 12 22:31 pdb2.7 -> ../lib/python2.7/pdb.py
lrwxrwxrwx 1 root root          23 10月 22 19:32 pdb3.6 -> ../lib/python3.6/pdb.py
lrwxrwxrwx 1 root root          31 10月 25 19:11 py3versions -> ../share/python3/py3versions.py
lrwxrwxrwx 1 root root          18 2月  23 15:44 python -> /usr/bin/python3.6
lrwxrwxrwx 1 root root           9 4月  16  2018 python2 -> python2.7
-rwxr-xr-x 1 root root     3670448 11月 12 22:31 python2.7
lrwxrwxrwx 1 root root           9 10月 25 19:11 python3 -> python3.6
-rwxr-xr-x 2 root root     4522328 10月 22 19:32 python3.6
-rwxr-xr-x 2 root root     4522328 10月 22 19:32 python3.6m
lrwxrwxrwx 1 root root          10 10月 25 19:11 python3m -> python3.6m
-rwxr-xr-x 1 root root         152 11月 11  2017 python3-pbr
lrwxrwxrwx 1 root root          29 4月  16  2018 pyversions -> ../share/python/pyversions.py
wu@acer:~$ python
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

猜你喜欢

转载自www.cnblogs.com/wuhuaxing/p/10422977.html
今日推荐