Skip to content

Instantly share code, notes, and snippets.

@jrwren
Created February 18, 2022 17:24
Show Gist options
  • Save jrwren/5b405c1efee1092bea86d8e0d33128a5 to your computer and use it in GitHub Desktop.
Save jrwren/5b405c1efee1092bea86d8e0d33128a5 to your computer and use it in GitHub Desktop.
a somewhat reasonable python2.7 on macos in 2022

a somewhat reasonable python2.7 on macos in 2022

Yes, this sucks, but look, there are still python2.7 projects out there. Homebrew did the wrong thing by removing their 2.7 forumla.

The system python2.7 doesn't have ability to install virtualenv or even pip. ☹️

That said, use homebrew to install zlib and bzip2 and maybe openssl as deps.

brew install openssl zlib bzip2
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/bzip2/lib -L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include"

I like to add those last 2 lines to my ~/.bashrc.

Download the Python 2.7 source tarball from python.org, extract it, and install.

curl -LO https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz
pushd Python-2.7.18
./configure --prefix=$HOME/python2.7  && make install

Add the python path to your path, maybe add this to your .bashrc. Install pip. install virtual env.

export PATH=$HOME/python2.7/bin:$PATH
python -m ensurepip --upgrade
pip install virtualenv

That is enough to get my project going. GL HF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment