JeremiahZhang / gopython

人生苦短, Python当歌.
9 stars 6 forks source link

How to install python 3.6 in Linux mint 18.1? #5

Closed JeremiahZhang closed 6 years ago

JeremiahZhang commented 6 years ago
$ python -V
$ python2 -V
$ python3 -V

查看系统安装的 python 版本.

Python 2.7.12
Python 3.5.2

我想使用最新的 python 3.6 版本.

参考:

Python 3.6 - install latest version into Linux Mint 文中的结果是 3.6 不会覆盖掉 3.5.

那么就先这样?

还是去 Python 官网看看.

目前 2017.10.01 python3 最新版 3.6.2

使用居然出错.

anifacc@mint ~ $ sudo add-apt-repository ppa:jonathonf/python-3.6
Cannot add PPA: 'No JSON object could be decoded'.

google it. 暂未解决. 目前不是主要问题.

JeremiahZhang commented 6 years ago
anifacc@mint ~ $ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
update-alternatives: using /usr/bin/python3.5 to provide /usr/bin/python3 (python3) in auto mode
anifacc@mint ~ $ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
update-alternatives: using /usr/bin/python3.5 to provide /usr/bin/python3 (python3) in auto mode

只有一个 pyhton3 版本, 这个没多大用.

JeremiahZhang commented 6 years ago

本来想让 python3 作为默认的 python interpreter.

找到这个提问: setting python 3.2.3 as default - Linux Mint Forums

说会导致系统崩溃. 还是不要了.

每次在 脚本开头 加上:

#!/usr/bin/env python3

然后 使用

$python my_script.py

还是使用 python2 interpreter

scripts - Why does Python in Linux require the line #!/usr/bin/python? - Ask Ubuntu

#!/usr/bin/python3

还是使用 python2 interpreter.

A

原来不是上面的使用方式, 而是直接使用

./my_script.py

如果 .py 脚本 没有made executable. 则会出现如下错误

anifacc@mint /media/anifacc/geek/gopython/Python-Programming-an-Introduction-to-CS/src/ch02 $ ./distance_convert.py
bash: ./distance_convert.py: Permission denied

查看信息: 我都不知道者具体意味着什么?需有后期和 Linux for fun 累积.

S/src/ch02 $ ls -ln *.py
-rw-r--r-- 1 1000 1000  403 Oct  1 16:28 avg2.py
-rw-r--r-- 1 1000 1000 1082 Oct  2 13:19 convert.py
-rw-r--r-- 1 1000 1000  438 Oct  2 13:35 distance_convert.py
S/src/ch02 $ ls -ln *.py
-rw-r--r-- 1 1000 1000  403 Oct  1 16:28 avg2.py
-rw-r--r-- 1 1000 1000 1082 Oct  2 13:19 convert.py
-rw-r--r-- 1 1000 1000  438 Oct  2 13:35 distance_convert.py

Q

我似乎还没有搞清楚 其使用.

:tired_face:


JeremiahZhang commented 6 years ago

直接解压 然后使用软连接 KO