MPT Florida
MPT Florida

Reputation: 5

Python code in OSX Terminal not compiling right

So I am trying to teach myself to program in Python while on spring break and I have run into a roadblock. I can get my code to compile in PyCharm, but I would really like to get it to compile correctly in Terminal because vim is my text-editor of choice. Does anyone have any idea of why my code may not be compiling correctly?

Here is my code compiling correctly in PyCharm

Here is my code compiling incorrectly in Terminal

Thank you in advance for any help.

Upvotes: 0

Views: 44

Answers (2)

Robert Polski
Robert Polski

Reputation: 36

Any recent OSX version comes with Python 2.7 as a standard. When you install Python 3.x, you have both versions on your system. The standard way of using python -command- in the terminal calls Python 2.7. You can call a command using python3 -command- instead to use Python 3.x. You could set an alias on python3 in .bash_profile to call it instead when you use python.

Upvotes: 1

PaulMcG
PaulMcG

Reputation: 63749

You have configured PyCharm to use an installed Python 3, but at the terminal you appear to be using Python 2. There is a difference in how the two versions output the results of print. Try modifying your terminal session to direct your path to use the installed Python 3 instead of the installed Python 2.

Upvotes: 0

Related Questions