1

enter image description hereI have this test code:

inputs = list(map(int, input().split()))
print(n)
print(inputs)

When I input 3 4 in the console below; I get the following error:

Traceback (most recent call last):
  File "/Users/Labhesh/PycharmProjects/algotoolbox/assignment1/test.py", line 2, in <module>
    inputs = list(map(int, input().split()))
  File "<string>", line 1
    3 4
     ^
SyntaxError: unexpected EOF while parsing

Process finished with exit code 1

When I run the same code from command line, there are no issues:

>> python3 test.py
>> 3 4
>> [3, 4]

Is there some special setting I have to do to make this simple code work in PyCharm?

EDIT

It seems that in pycharm project interpreter is not the same as run configuration. To set Run configuration - use Run --> Edit Configuration and then choose the python interpreter.

You can also do

import sys
print(sys.version) 

to print the runtime version

1 Answer 1

1

It appears that PyCharm may be using a 2.x version of Python.

When run using python 3.5 in PyCharm:

"C:\Program Files (x86)\Python35-32\python.exe" "C:\Program Files (x86)\JetBrains\PyCharm 2016.3\helpers\pydev\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 59807 --file C:/src/testcode/test.py
pydev debugger: process 12684 is connecting

Connected to pydev debugger (build 163.10154.50)
3 4
[3, 4]

Process finished with exit code 0

When run using Python 2.7 in PyCharm:

C:\Python27\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 2016.3\helpers\pydev\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 59813 --file C:/src/testcode/test.py 
pydev debugger: process 16920 is connecting

QSslSocket: cannot resolve SSLv2_client_method
QSslSocket: cannot resolve SSLv2_server_method
Connected to pydev debugger (build 163.10154.50)
3 4
Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3\helpers\pydev\pydevd.py", line 1596, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3\helpers\pydev\pydevd.py", line 974, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:/src/testcode/test.py", line 13, in <module>
    inputs = list(map(int, input().split()))
  File "<string>", line 1
    3 4
      ^
SyntaxError: unexpected EOF while parsing
Sign up to request clarification or add additional context in comments.

3 Comments

see the screenshot I just added (to my original post), the project interpreter is 3.5
Project interpreter is not necessarily the same as run time. EG: see what I posted, it came from the same project.
you are correct, print(sys.version) gives me 2.6.6. How do I set the runtime to be 3.5?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.