I was running NVMain but got a python error. I'm using python 2.7.18, but ended up on missing parenthesis error and as I read everywhere python 2.7 supports no brackets but why the error is still existing. I am attaching a picture of error.
Asked
Active
Viewed 530 times
-1

ShadowRanger
- 143,180
- 12
- 188
- 271

Learning
- 29
- 1
-
Are you using a virtualenv? How did you install SCons? – bdbaddog May 07 '21 at 21:29
1 Answers
1
You're not using Python 2.7. You're using scons
, which is choosing its own interpreter (I'm assuming it's a script, so you can just open it in a text editor, it likely has a shebang line at the top that refers to python3
). As of scons
version 4.0.0, it doesn't support Python below 3.5 at all, so your SConscript
files need to be written in Python 3 compatible syntax.

ShadowRanger
- 143,180
- 12
- 188
- 271
-
ok...I just changed the python from 2.7 to 3.8 but still, the same problem persists. why? umakant@umakant-Vostro-15-3568:~/$ python -V Python 3.8.5 umakant@umakant-Vostro-15-3568:~/gem5-nvmain-hybrid-simulator-master/nvmain$ scons --build-type=fast scons: Reading SConscript files ... File "/home/umakant/gem5-nvmain-hybrid-simulator-master/nvmain/build/SConscript", line 57 print "Checking gem5 revision number...", ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Checking gem5 revision number...", end=" ")? – Learning May 07 '21 at 06:35
-
1@Learning No, you got it backwards. No-parentheses `print` is a *Python 2* construct, and is invalid in Python 3. The problem is that scons is running your code using Python 3, not 2. – deceze May 07 '21 at 06:36
-
@Learning: As I said in the answer, rewrite your `scons`-related code (e.g. `SConscript`) to be Python 3 compatible, e.g. using `print` function (which requires parentheses), not `print` statement (Python 2-only weirdness). The `2to3` helper might do a lot of it for you, but all the possible things you might need to change are beyond the scope of StackOverflow; there were a handful of big, annoying things to deal with, and dozens of small, mostly automatable changes. – ShadowRanger May 07 '21 at 10:07