How to use Python on Mac

39.4K views
6 min read

Every year, more and more people realize the value of coding. In fact, learning to code is going through a boom nowadays. It’s empowering, challenging, and offers great job opportunities.

One of the most popular general-purpose programming languages is Python. It’s easy enough to pick up even for absolute beginners and robust enough to be used by scientists working at the cutting edge of machine-learning exploration. 

Still, you might not exactly know the answer to questions like how to code in Python, how to update Python on Mac, what are the best Python editors Mac supports, etc. So let’s take a closer look at everything you need to know about Python for Mac. 

What Can You Do with Python Mac Code?

Everyone says that Python is great and an easy programming language to start with. But why is that exactly? And what are the benefits of Python compared to other languages? 

Python is considered “simple” because of its clear syntax that you can learn to read pretty quickly — which means you’ll spend less time on the structure and more time on the actual content. 

Python is also powerful and multi-purpose. You can use it to write simple scripts and automate everyday tasks, you can create web apps, you can do research, you can use it in design, and you can experiment with machine learning as well. 

Python is open source and free to use, and gets regularly updated. And if you ever get stuck, Python’s expansive and supportive community is there to help you out. 

Finally, Python is one of the most popular programming languages and is always in demand (just as Java and JavaScript are) if you’d like to switch careers. 

How to download Python for Mac

When you’re thinking about how to use Python, the good news is it’s already installed on your Mac, since it comes with macOS and lots of default Mac utilities rely on Python. 

However, the version of Python on your Mac is likely to be outdated. The current latest release of Python is 3.9.4 (from April 4, 2021). Usually the language gets new minor updates every month or so. 

To check the current version of Python on Mac:

  1. Launch Terminal from Utilities
  2. Type: python --version
  3. Press Return 

    check-python-version-mac

Luckily, you can download Python for Mac at any time: 

  1. Visit python.org/downloads
  2. Click Download Python
  3. Double-click the package file on your Mac
  4. Proceed through the installation 

    download-python-latest-version-mac

To check that Python on Mac has updated properly, launch Terminal again and type: python3 --version

Note: When updating Python to version 3.x, don’t try to delete the old Python version 2.x from your Mac. That’s because your Mac utilities are actually made to use the old version, and deleting it could cause all sorts of critical errors to come up.

What’s the best Python editor Mac supports?

By default, any Python file (with .py extension) would open in Mac’s default TextEdit. But TextEdit is not even remotely the best editor you can use. It lacks the ASCII format and doesn’t let you structure everything the way it should be. 

When you download Python as shown above, you’ll also get Python’s IDLE (integrated development and learning environment) editor installed. It’s good enough to get you up and running since it lets you edit your code and see the output in the same place. But there are also better options out there. 

python-idle-editor-mac

CodeRunner is a multi-language IDE and editor that you can use at any programming level for practically any programming task. It’s lightning-fast, supports 25 languages out of the box (including Python), and has more than 230 features as well as customizable preferences and work modes. CodeRunner follows the industry-standard syntax (e.g. code completion, auto-indenting, bracket management), so you don’t have to tweak anything to get it to work properly. Plus, debugging tools make cleaning up your code a breeze.  

coderunner-python-editor-mac

PyCharm is a very popular Python-specific IDE, with a free and paid version available. This editor embraces keyboard-led approach, with shortcuts helping you program faster. You also get on-the-fly code error checks, access to plugins, and web development support. 

pycharm-editor-python-mac

Sublime Text is the most flexible editor that extends beyond code into markup and prose as well. It’s fast, lightweight, and has an unlimited free trial. Sublime Text is loved for its power features like multiple selections, split editing, and more that don’t get in the way if you don’t need them. 

sublime-text-editor-python-mac

Having a great Python editor Mac runs natively is essential. But you’ll likely need a few more tools to make your programming a joy.

Whisk is an award-winning web editor for Mac. Unlike other text editors that can handle Python, Whisk focuses on helping your edit HTML, CSS, PHP, and JavaScripts, and make your websites look great with less effort. Whisk features live previews, instant publishing, and server or CDN integration. 

web text editor

Dropzone is not a text editor, but is nevertheless just as critical. This nifty utility can save you hours of time by pre-saving complex shortcuts and actions, and then repeating them instantly with a certain trigger. So you can shorten URLs, upload files to your FTP server, resize images, etc. You can also create your own shortcuts to make your development workflow easier. 

dropzone-shortcuts-creator-mac

How to use Python to start programming

Now that you have a text editor of your choice like CodeRunner and other helpful tools like Whisk and Dropzone, how do you actually start programming Python on Mac?

The first step is to open CodeRunner and make sure it’s set to Python in the top-left corner dropdown. 

Then let’s print Hello World. To do this, type: print("Hello World”). After that, click Run in the top menu, and Hello World will be printed in the other window. 

You can also use the print command to calculate simple arithmetics. For example, if you type print(10+10) and run the command, it’ll output 20. 

Python also makes it easy to create conditional statements. For example, type: 

weather = 100

if weather > 75:

print(“It’s hot outside”)

else:

print(“It’s not hot outside”) 

coderunner-how-to-code-python-mac

Then run the command to get the answer. These are just the most basic commands, but you can already see the potential in them. Programs are essentially built out of small blocks of simple conditional statements and algorithms. So if you just devote a little bit of time every day to getting better at Python, in a few months, you’ll be able to build truly impressive working scripts and applications that you never thought you could do! There are literally thousands of courses, both free and paid, online to get you started.

As you can see, learning how to code in Python is not that intimidating when you have the right tools from the beginning. So make sure you learn in the proper environment of CodeRunner, with Whisk there to assist you for any HTML/CSS tasks and Dropzone to make repeating actions a breeze.

Best of all, CodeRunner, Whisk, and Dropzone are available to you absolutely free through the seven-day trial of Setapp, a platform with more than 210 top-of-the-line Mac apps for any task, from writing prose (Ulysses) to controlling your network traffic (TripMode). Try every Setapp app right now at no cost and find your new favorites to improve your daily productivity.

250+ apps for $9.99
per month

Sign up to Setapp and try them for free.

Security-tested