Skip to content

Before you proceed..

Check Python Installation

Check to see if you installed Python correctly. In a fresh Terminal window, type in the following command:

python --version

If you installed it correctly, you should be able to view the Python version installed and being used in your machine.

If you used Homebrew

READ THIS FIRST - If you don't know what Homebrew is, just skip this section.

If you do know what Homebrew is, chances are you may have used it to install Python in your macOS system. If you chose to install it this way, chances are there is not an obvious link to using IDLE app, unlike if you went with installing using the .dmg file.

I believe you can open up IDLE by typing in the following in a Terminal window:

idle   # You may need to type "idle3" instead if this does not work.

Now, there is a high chance that you may encounter an error message that says the following:

** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **

Tkinter is what Python uses to be able to render graphical user interfaces from Python code. This can prove helpful especially if you want to display graphical data in Python, or using Turtle (as will be introduced during the early lectures in the semester). To obtain Tkinter, you will need to install it again with Homebrew:

brew install python-tk

With that, you should be able to load IDLE from your macOS machine fine now. Feel free to consult other online references to continue troubleshooting the problem from here if this has not yet resolved your problem.

You can still use other code editors/IDEs to program in Python with if you choose not to use IDLE here.

References

If you used Pyenv

READ THIS FIRST - If you don't know what Pyenv is, just skip this section.

To be able to run IDLE with Python installed using Pyenv, you will first need Tkinter installed:

brew install tcl-tk

From here, just run the following command, replacing <version> with your current version of Python and you should then be able to invoke IDLE from the Terminal:

env \
  PATH="$(brew --prefix tcl-tk)/bin:$PATH" \
  LDFLAGS="-L$(brew --prefix tcl-tk)/lib" \
  CPPFLAGS="-I$(brew --prefix tcl-tk)/include" \
  PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" \
  CFLAGS="-I$(brew --prefix tcl-tk)/include" \
  PYTHON_CONFIGURE_OPTS="--with-tcltk-includes='-I$(brew --prefix tcl-tk)/include' --with-tcltk-libs='-L$(brew --prefix tcl-tk)/lib -ltcl8.6 -ltk8.6'" \
  pyenv install <version>
References