首页 技术 正文
技术 2022年11月18日
0 收藏 820 点赞 2,444 浏览 1553 个字

如果你使用的是Linux发行版,例如Ubantu,那么你的系统中可能已经安装好python了。可以使用python -v来测试一下:

ortonwu@ubuntu:~$ python -V
Python 3.5.2

当然,这是我安装了Python3之后显示的。如果你测试出来你的系统安装的是Python 2.7或是提示command not found,想升级或安装Python3的话,可以使用如下命令下载最新的Python:

sudo apt-get install python3

输入root密码后下载完成。输入python可以进入python的命令行交互:

ortonwu@ubuntu:/usr/bin$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

这里显示的Python版本是2.7,而不是刚下载的3.5。这是因为python被软连接到python2.7了。可以在/usr/bin下查看python link文件:

ortonwu@ubuntu:~$ ll /usr/bin/ | grep ^l | grep python
lrwxrwxrwx 1 root root 26 Apr 1 20:11 dh_pypy -> ../share/dh-python/dh_pypy*
lrwxrwxrwx 1 root root 29 Apr 1 20:11 dh_python3 -> ../share/dh-python/dh_python3*
lrwxrwxrwx 1 root root 23 Nov 19 01:36 pdb2.7 -> ../lib/python2.7/pdb.py*
lrwxrwxrwx 1 root root 23 Nov 17 11:26 pdb3.5 -> ../lib/python3.5/pdb.py*
lrwxrwxrwx 1 root root 31 Apr 1 20:11 py3versions -> ../share/python3/py3versions.py*
lrwxrwxrwx 1 root root 26 Apr 1 20:11 pybuild -> ../share/dh-python/pybuild*
lrwxrwxrwx 1 root root 18 Apr 25 07:43 python -> /usr/bin/python3.5*
lrwxrwxrwx 1 root root 9 Apr 1 20:11 python2 -> python2.7*
lrwxrwxrwx 1 root root 9 Apr 1 20:11 python3 -> python3.5*
lrwxrwxrwx 1 root root 10 Apr 1 20:11 python3m -> python3.5m*
lrwxrwxrwx 1 root root 29 Apr 1 20:11 pyversions -> ../share/python/pyversions.py*

重新建立到python3.5的软连接即可:

ortonwu@ubuntu:/usr/bin$ sudo rm -rf python
ortonwu@ubuntu:/usr/bin$ sudo ln -s /usr/bin/python3.5 /usr/bin/python

这时使用python即可进入python3.5命令行交互界面:

ortonwu@ubuntu:/usr/bin$ python
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,105
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,582
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,429
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,836
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,919