Skip to content

Instantly share code, notes, and snippets.

@jj1bdx
Last active February 23, 2019 16:23
Show Gist options
  • Save jj1bdx/0315955cdc8e2dde0283 to your computer and use it in GitHub Desktop.
Save jj1bdx/0315955cdc8e2dde0283 to your computer and use it in GitHub Desktop.
Updating python, pip, setuptools/easy_install on OS X with HomeBrew

Updating Python on OS X with HomeBrew

Updating Python library with HomeBrew could be a painful experience. Upgrading setuptools and pip may cause version disruption and will render pip and easy_install useless.

Here's a list of commands for the install process, FYI.

# disable virtualenv before doing this
umask 022
brew update
brew upgrade
cd /usr/local/lib/python2.7/site-packages
/bin/rm -rf pip*
/bin/rm -rf easy_install.pth
brew rm python && brew install python
pip install --upgrade setuptools
pip install --upgrade pip
# NOTE: edit pip version number manually
vim -X /usr/local/bin/pip
# NOTE: edit setuptools version number manually
vim -X /usr/local/bin/easy_install
# check whether pip and easy_install work
pip
easy_install
# check installed library versions
pip freeze
# without doing this virtualenvwrapper and stevedore libs will not be installed
export LC_CTYPE="C"
# install virtualenvwrapper
pip uninstall virtualenvwrapper
pip uninstall virtualenv-clone
pip uninstall virtualenv
pip uninstall stevedore
pip install stevedore
pip install virtualenv
pip install virtualenv-clone
pip install virtualenvwrapper
# install sphinx
easy_install sphinx
# install Pillow too
easy_install Pillow
# check Sphinx and Pillow version
pip freeze
# check if Sphinx really works
sphinx-quickstart

On pip and easy_install versions

This is a copy of /usr/local/bin/pip. You need to manually fix the version numbers as in pip==1.5.5, with the latest pip version number installed in /usr/local/lib/python2.7/site-packages.

You also have to do this for /usr/local/bin/easy_install: the version number here is setuptools==3.6 (note well the name difference).

I think this is lame and disappointing, but this is the easiest way to fix things.

#!/usr/local/opt/python/bin/python2.7
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==1.5.5','console_scripts','pip'
__requires__ = 'pip==1.5.5'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('pip==1.5.5', 'console_scripts', 'pip')()
    )

references

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