python SyntaxError: Missing parentheses in call to ‘print‘. Did you mean print(“hello,world!“)

Ubuntu 18.04 +python3.6 编译时有语法错误(SyntaxError):

SyntaxError: Missing parentheses in call to 'print'. Did you mean print("hello,world!")

原来是环境里默认的python版本是3.6,而编译Makefile里的引用的是phthon2.x版本的语法;

可以有以下两种方法解决:

1.print 后面的log加括号,如: print hello,world ========>print("hello,world!")

2.降级python版本到2.x:

sudo rm /usr/bin/python

sudo ln -s /usr/bin/python2.7 python

然后确认下是不是指信python2.7

sudo ls -la /usr/bin/python*

lrwxrwxrwx 1 root root       9 Nov 25 02:11 /usr/bin/python -> python2.7
lrwxrwxrwx 1 root root       9 Apr 16  2018 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3628976 Sep 30 06:38 /usr/bin/python2.7
lrwxrwxrwx 1 root root       9 Jul  8 22:49 /usr/bin/python3 -> python3.6
-rwxr-xr-x 2 root root 4526456 Oct  8 05:12 /usr/bin/python3.6
-rwxr-xr-x 2 root root 4526456 Oct  8 05:12 /usr/bin/python3.6m
lrwxrwxrwx 1 root root      10 Jul  8 22:49 /usr/bin/python3m -> python3.6m
lrwxrwxrwx 1 root root      58 Mar  5  2018 /usr/bin/pythontex -> ../share/texlive/texmf-dist/scripts/pythontex/pythontex.py
-rwxr-xr-x 1 root root     306 Mar  5  2018 /usr/bin/pythontex3

然后执行shell时正常了。

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值