DEV Community

Martin Breuss
Martin Breuss

Posted on • Originally published at Medium on

All you need for working with Python 3 on a Mac

To clear up any confusion about a functioning setup to start working with Python 3 on a fresh Mac — here’s a quick (minimal) guide.

DO #1: download and install Python 3.x.x

Go to the official website and download Python from there. Yes — since you’re asking —  do get the latest version (the one with the shiny yellow button):

Execute the installer and step through the required steps…

(it’s easier than that)

And if you’re on Mavericks (10.9) or above, you’re (nearly) done.

>> Really? Proof it!

Open your Terminal and verify by typing:

python3 --version
Enter fullscreen mode Exit fullscreen mode

which should respond to you with something similar to: Python 3.7.0

Then type:

git --version
Enter fullscreen mode Exit fullscreen mode

which should either:

  • prompt you to install the command-line tools. If so, allow that install (it’ll bring version control to your life!). This is, btw, the step that completes the “(nearly)” from above.
  • or, if it’s already there, it will say something like: git version 2.15.2 (Apple Git-101.1)

Finally, you can also ask your patient terminal the following:

pip3 --version
Enter fullscreen mode Exit fullscreen mode

and it will dutifully respond with a lengthy: pip 18.0 from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)

And with that you are all set up and ready to dive into writing code with Python 3 , and installing whatever package you may fancy from Python’s rich ecosystem on pypi.org using pip3 (create a virtual environment first!), and indulge in the reassuring beauty of version control with git.

>>> What if your OS is older than 10.9?

Update it. It’s free and makes your computer better.

If for any reason you can’t update your OS but still want to proceed working with Python 3 and git, then get Git from here:

A macOS Git installer is maintained and available for download at the Git website, at http://git-scm.com/download/mac.

You made it! Good job! Now, for your enjoyment, here’s a list of steps that are often mentioned in tutorials on how to get started, but IMO they only complicate the basic setup.

DON’T #1: install Anaconda

Anaconda is a great tool for data analysis , however, it comes with a lot of stuff. Anaconda is a full-blown Python distribution (= it’s its own version of Python!), that comes with its own package manager, tons of data science packages pre-installed, and oh — did I mention it also includes R?!

DON’T #2: install homebrew

Every second tutorial tells you to install homebrew first, and then use it to get python on your mac. Don’t do it. There’s no need.

I personally don’t like cellars very much, and even though I tried to homebrew a couple of years ago (I only drank it for the experience, not the taste ;) that alone can’t win me over for the easily forgettable and potentially already long-forgotten leftovers that homebrew’s Cellar structure induces on my machine.

DON’T #3: install pip

You don’t have to force-install pip if you download Python 3 from the official download page. It comes along voluntarily.

the official pip site speaks:

pip is already installed if you are using Python 2 >=2.7.9 or Python 3 >=3.4 downloaded from python.org

+/- useful tutorials

Other Resources

Top comments (1)

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

Actually, homebrew might be useful for other things as well.

There is pyenv, but probably you don't like it as well?

As for Anaconda, although personally I haven't tried it, I think it might be useful to install slowly-compiled C/C++ once and for all. But that depends on how far you want to venture into data science. (Also, R language isn't so bad.)