我无法在 ubuntu 14.04 上运行 python3
alias python=python3
python --version
输出:
Python 2.7.6
和
python3 --version
给出相同的输出
据我了解,系统应该预装了python3?
我尝试运行:
sudo apt-get install python3
但是有一个错误:
Setting up idle-python3.4 (3.4.3-1ubuntu1~14.04.3) ...
File "/usr/lib/python3.4/compileall.py", line 120
print('*** ', end='')
^
SyntaxError: invalid syntax
dpkg: error processing package idle-python3.4 (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
idle-python3.4
请您参考如下方法:
检查是否安装了python3:
python3 --version
将 alias python=python3 添加到 ~/.bashrc 或 ~/.bash_aliases 文件中。
您必须注销然后重新登录。
我建议对 python 3.x 使用 python3。有很多程序依赖于 python 2.x,所以最好不要删除它。但是你可以卸载它:sudo apt-get remove python2.7
在卸载 Python 2.7 之前阅读 this .
