[英]can't run python3 on ubuntu
I can't run python3 on ubuntu 14.04 我无法在Ubuntu 14.04上运行python3
alias python=python3
python --version
outputs: 输出:
Python 2.7.6
and 和
python3 --version
gives same output 给出相同的输出
As I understand python3 should be preinstalled on the system? 据我了解,python3应该预先安装在系统上吗?
I tried to run: 我试着跑:
sudo apt-get install python3
But there is an error: 但是有一个错误:
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
Check if python3
is installed: 检查是否安装了
python3
:
python3 --version
Add alias python=python3
into ~/.bashrc
or ~/.bash_aliases
file. 将
alias python=python3
添加到~/.bashrc
或~/.bash_aliases
文件中。
You must logout then login again. 您必须注销然后再次登录。
I recommend using python3
for python 3.x. 我建议将
python3
用于python3.x。 There are a lot of programs depending on python 2.x so better not to remove it. 有很多程序取决于python 2.x,因此最好不要删除它。 However you can uninstall it:
sudo apt-get remove python2.7
但是您可以卸载它:
sudo apt-get remove python2.7
Before uninstalling Python 2.7 read this . 在卸载Python 2.7之前,请阅读此内容 。
You misunderstand how aliases work. 您误解了别名的工作原理。 You need to reset the hash table via
hash -r
(see man bash
for details). 您需要通过
hash -r
重置哈希表(有关详细信息,请参见man bash
)。
Also: 也:
edd@max:~$ python3 --version
Python 3.5.1+
edd@max:~$ lsb_release -d
Description: Ubuntu 16.04 LTS
edd@max:~$
and 和
edd@max:~$ ls -l /usr/bin/python*
lrwxrwxrwx 1 root root 9 Dec 9 2015 /usr/bin/python -> python2.7
lrwxrwxrwx 1 root root 9 Dec 9 2015 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 2629712 Aug 11 2011 /usr/bin/python2.6
-rwxr-xr-x 1 root root 3546104 Jul 2 14:05 /usr/bin/python2.7
lrwxrwxrwx 1 root root 33 Jul 2 14:05 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root 16 Dec 9 2015 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root 9 Mar 23 06:00 /usr/bin/python3 -> python3.5
lrwxrwxrwx 1 root root 11 Oct 19 2012 /usr/bin/python3.2 -> python3.2mu
-rwxr-xr-x 1 root root 2863832 Oct 19 2012 /usr/bin/python3.2mu
-rwxr-xr-x 2 root root 4439120 Mar 31 06:51 /usr/bin/python3.5
-rwxr-xr-x 2 root root 4439120 Mar 31 06:51 /usr/bin/python3.5m
lrwxrwxrwx 1 root root 10 Mar 23 06:00 /usr/bin/python3m -> python3.5m
lrwxrwxrwx 1 root root 16 Dec 9 2015 /usr/bin/python-config -> python2.7-config
lrwxrwxrwx 1 root root 58 Mar 25 17:01 /usr/bin/pythontex -> ../share/texlive/texmf-dist/scripts/pythontex/pythontex.py
-rwxr-xr-x 1 root root 306 Mar 25 17:01 /usr/bin/pythontex3
edd@max:~$
You want to look into dpkg-alternatives
to switch the default from python2
to python3
. 您想研究
dpkg-alternatives
将默认值从python2
切换到python3
。 I'd be careful though as some system scripts may expect python
to be version 2. 我会小心一点,因为某些系统脚本可能期望
python
为版本2。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.