I had to scp the python-2.7.14.tar.xz file over to a current CentOS box, run the “unxz” utility to decompress the 12 mb file into a 71 mb file, and scp it back to the laptop, where I could then do the./configure, make and make install (I wanted to overwrite the old Python version). Now, we can install Python 2.7: $ brew install [email protected] Because [email protected] is a “keg”, we need to update our PATH again, to point at our new installation.
Check out our guide for installing Python 3 on OS X.
Mac OS X comes with Python 2.7 out of the box.
You do not need to install or configure anything else to use Python. Having saidthat, I would strongly recommend that you install the tools and librariesdescribed in the next section before you start building Python applications forreal-world use. In particular, you should always install Setuptools, as it makesit much easier for you to install and manage other third-party Python libraries.
The version of Python that ships with OS X is great for learning, but it’s notgood for development. The version shipped with OS X may be out of date from theofficial current Python release,which is considered the stable production version.
Doing it Right¶
Let’s install a real version of Python.
Before installing Python, you’ll need to install a C compiler. The fastest wayis to install the Xcode Command Line Tools by running
xcode-select--install. You can also download the full version ofXcode from the Mac App Store, or theminimal but unofficialOSX-GCC-Installerpackage.
If you already have Xcode installed, do not install OSX-GCC-Installer.In combination, the software can cause issues that are difficult todiagnose.
If you perform a fresh install of Xcode, you will also need to add thecommandline tools by running
xcode-select--install on the terminal.
While OS X comes with a large number of Unix utilities, those familiar withLinux systems will notice one key component missing: a decent package manager.Homebrew fills this void.
To install Homebrew, open
Terminal oryour favorite OS X terminal emulator and run
The script will explain what changes it will make and prompt you before theinstallation begins.Once you’ve installed Homebrew, insert the Homebrew directory at the topof your
PATH environment variable. You can do this by adding the followingline at the bottom of your
Now, we can install Python 2.7:
[email protected] is a “keg”, we need to update our
PATH again, to point at our new installation:
Homebrew names the executable
python2 so that you can still run the system Python via the executable
Setuptools & Pip¶
Homebrew installs Setuptools and
pip for you.
Setuptools enables you to download and install any compliant Pythonsoftware over a network (usually the Internet) with a single command(
easy_install). It also enables you to add this network installationcapability to your own Python software with very little work.
pip is a tool for easily installing and managing Python packages,that is recommended over
easy_install. It is superior to
easy_installin several ways,and is actively maintained.
A Virtual Environment (commonly referred to as a ‘virtualenv’) is a tool to keep the dependencies required by different projectsin separate places, by creating virtual Python environments for them. It solves the“Project X depends on version 1.x but, Project Y needs 4.x” dilemma, and keepsyour global site-packages directory clean and manageable.
For example, you can work on a project which requires Django 1.10 while alsomaintaining a project which requires Django 1.8.
To start using this and see more information: Virtual Environments docs.
This page is a remixed version of another guide,which is available under the same license.
May 29th, 2020
- Link toInstalling the latest version of Python on Mac OS Catalina and overriding the old default pre-installed versionpodcast on anchorfm
I finally did it. I successfully installed
Homebrew on my Maclaptop with
For those of you that still might be trying to figure outhow todo this, I will walk you through.
The reason why I was eager to make sure that I had the latest versioninstalled was because I am working on publishing (open-source)teaching-related
Read The Docs, and I need to have
Pythoninstalled in order to be able to install the programsnecessary to
2.7.17 version of
Python was retired this past
January 2020. I had tried back then to replace it with
Python 3+,but was unsuccessful at the time. The following is what I did today:
First I updated
Homebrew. Yes, I used
Homebrew to (re)install
Python. It’s really easy. It’s just a matter of putting the pieces of thepuzzle together correctly!
I ran the
Brew Install Python 2.7.3
Homebrew. Then I ran the
Python. Then I ran
Brew Install Python 2.7 2021
To see which version of
Mac laptop was recognizing. Itstill recognized only
Python 2.7.17. So I ran the following
It told me the
path to my newly installed
Python 3.7.7. I had tochange the
Python in order for my
Mac to recognize thenewly installed version. This is what the command
brew info python returned tome in Terminal:
So I had to add the following at the bottom of my
.zshrc fileto update the
path to my newly installed version of
Then I made sure to quit
Terminal and go back in so that the
pathwould actually be updated in a new
Then I checked what
Python was recognized now with
And this is what was returned:
Success! It’s as easy as that.
And BTW, if you don’t know how to access your
.zshrc file in
Catalina,you simply execute the following
And your file will open in a new window. Then you can paste
At the bottom of the file.
I will be embedding this episode of Plugging in The Holes along with atranscript in the form of a post oninterglobalmedianetwork.com for yourhearing and reading pleasure. Bye for now!
Brew Install Python 2.7 Online
Created by Maria D. Campbell who lives and works in New York City building useful things.You should follow her on Twitter. She also has a developer blogmariadcampbell.comyou may want to check out!