I have a foo.py Python file containing print 'bar'
code.When I want to python foo.py
my code, here is the error : SyntaxError: Missing parentheses in call to 'print'
. Do you know how to avoid this error without adding '(' and ')' to my print
function ?
Thanks !
1 Answer
If your script is compatible then you can force use of Python2 by running it something like
python2 foo.py
Dec 25, 2016 Join GitHub today. GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together. I have a foo.py Python file containing print 'bar' code. When I want to python foo.py my code, here is the error: SyntaxError: Missing parentheses in call to 'print.
or
python2.7 foo.py
That is, of course, to purely answer your question as to 'using the command line to bypass' the issue.
A rewrite of the code for either 2-and-3 compatibility, using 2to3 for conversion, or refactoring for Python3 would be the other non-command-line approach.
Not the answer you're looking for? Browse other questions tagged command-linepythonprintingpython3 or ask your own question.
This question already has an answer here:
- What does “SyntaxError: Missing parentheses in call to 'print'” mean in Python? 6 answers
I'm a gamer who decided he wanted to make some basic games others could play. I'm very new to coding and have the most basic understanding of it. My cousin and I are trying to make a text based game in Python 3.6.0. We have searched the internet for answers to our problem, but cannot find anything. Code is below:
When trying to run the module to test it, we get an error which says:
'Missing parentheses in call to 'print'
Since we have such a basic knowledge of coding, and couldn't find answers on google, we were hoping that someone could help fix this most likely, simple error.
squiguymarked as duplicate by DeepSpace, David Z pythonDec 27 '16 at 7:51
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1 Answer
This is very basic problem but because you seem completely new to everything...
The print
'statement' in Python 3.x is a function that uses parenthesis so:
Is now
kentwaitkentwait