Legend

Potential Audience:

  • Learners wanting to use a free but industrial-grade Python IDE on a Mac.
  • Anyone having trouble using Python on Visual Studio Code because it ‘won’t run’.

Why Mac?

Unless you are Jabba, the Meister Programmer, I advise all learners to use MacOS for the smoothest possible journey in their quest to become programmers.

That’s because at its heart, MacOS is simply a flavor of Unix and you can’t do serious programming on Windows–that’s a fact acknowledged by Microsoft, too (hence their providing the WSL).

Digression: What is WSL?
WSL stands for Windows
Subsystem for Linux.

In other words, many important tools, tips, and programming-related matters are readily available for Unix, via its terminal.

How to correctly install Python in 2023?

Want extra bloatware on your already full computer? And what about path conflicts and other disasters?

The easiest, most professional and bloatware-free way to install Python on your Mac to use the Homebrew! Dont’ scoff yet. Homebrew in 2023 is completely revamped and works like butter.

All you have to do (in terminal):

brew install python

Brew creates an independent path folder that prevents conflict. Nor do you need Sudo at all (less hassle). Ok you’ve done that, now you have also installed Visual Studio Code. You write:

print('Does Python hiss?')

There are several ways to run this program, but today you will learn the most user-friendly one (hence the justification for this post, as most Python installation and running advice elsewhere is outdated or unnecessarily complicated.)

So next, install the Code Runner extention in the Plugin section (I assume you know how to do that!). After that, you will see a ‘play’ button in the top right corner of your IDE. Don’t press it!!

Right-click and you will see several options. At the very bottom, you will see:

Run current file in interactive window

Which is what you should click. Et voila!

To Recap

  • Install Python via Homebrew.
  • Install Code Runner on VSCode.
  • Use Interactive mode to run your Python.

It must be noted that the interactive version is for learning and experimentation and not production or real-world use.

Also, although you can do

Python3 hello.py in your terminal, it’s boring.

Finally, please note that you don’t have to right-click each time you want to run your Python code! The first right-click selects the interactive mode, but thereafter you just click on the ‘run’play’ button and your code should run.