leojacoby
leojacoby

Reputation: 85

Python 3.5 running in IDLE shell, but not macOS Terminal

I'm trying to get Python 3.5 to run in my terminal. I made a script using idle that printed out the version of python in use to try to solve my problem. The script looked like this:

import sys
print(sys.version_info)

When I ran it in IDLE, I got the following output:

sys.version_info(major=3, minor=5, micro=2, releaselevel='final', serial=0)

When I ran it in terminal, I got the following output instead:

sys.version_info(major=2, minor=7, micro=10, releaselevel='final', serial=0)

I want to be able to run my scripts in terminal because I want to be able to access files and use pip. If you know how I can do one or both of these things in the IDLE shell, or you know how to update terminal so I can do this.

Upvotes: 0

Views: 1196

Answers (2)

techydesigner
techydesigner

Reputation: 1691

Running Python from the terminal

If you have Python installed, then:

  • python or python2 opens the interactive prompt or runs a script if a file is supplied as an argument
  • python3 does the same as above, but for Python 3

Note that if Python 3 is set as the default Python version, then running python will use Python 3

Running IDLE from the terminal

If you have IDLE installed, then:

  • idle2 opens IDLE for Python version 2
  • idle3 opens IDLE for Python version 3 (unless you change the default python)

Changing the default Python version

If you want Python 3 to be the default Python version, then take a look at this SO question: How to set Python's default version to 3.3 on OS X? Be aware that there are some disadvantages and things to work around, so I advise you to read the entire article if you do so.

Upvotes: 1

Wasi
Wasi

Reputation: 1492

To run idle from command line Type idle3 in the terminal for Python 3 idle and if you want to run Python 2 idle, type idle in the terminal .

Similarly, if you need to run a script or python prompt from terminal you should type python3 when you want to use Python 3 and python when you want to run Python 2.

Upvotes: 0

Related Questions