# Hi # # Last updated: Feb 27 2016 # # These notes are for installing "modern" python (3.4) on ubuntu 12.04 # This is explicity for people who followed the well-meaning advice at # http://askubuntu.com/questions/412178/how-to-install-pip-for-python-3-in-ubuntu-12-04-lts/412179#comment1100126_412179 # which might have worked when written but as of Feb 2016, really # breaks a python install. # # Note that this could *become* a script with a little bit of editing but # currently every command is wrapped in a function which intentionally is not # invoked. # # Read the comments before you blindly run them on your system. Some of them # intentionally "burn the village" and state as much. # dump_python() { # First dump pip3 easy_install3 -m pip # This still leaves things around so we have to dump them manually # It's easy_install, not easy_uninstall # # we dump them all because they're all currently broken. rm /usr/local/bin/pip3* # Now we dump the egg manually. We presume # All the pips here are busted or not supported (100% true). rm -fr /usr/local/lib/python3.2/dist-packages/pip-* # And now we dump all variations of python3 so as # not to mess things up again. This will make the # screen look scary but if you look at the list, it's # just python3. the purge gets rid of things that suggest # a python3.2 should exist somewhere. It shouldn't. # # This will also remove things like python3.3 and 3.4 # which it ostensibly looks like it shouldn't (it should, # that's another discussion). This is what we WANT because # we don't preferably want a bunch of 3.x versions lying # around since there apparently are intentional breaks # for 3.x versions of python's core utils. # # It's best to be (as of Feb 2016) in 3.4 or higher. # # Note: If you don't do the above dump of pip3 first, then # you will be stucks with those files lurking around without # the python 3.2 infrastructure of easy_install to remove them # in the way listed above apt-get purge python3.2\* } get_python34() { # Now that we've unhosed our system of broken python3 we need to # redo this with python 3.4+ which will not break with pip8 # see https://www.reddit.com/r/Python/comments/20xims/is_there_an_easy_way_to_install_python_34_on/ add-apt-repository ppa:fkrull/deadsnakes apt-get update apt-get install python3.4 # You probably also need these libraries for building packages # such as pycurl or lxml apt-get install python3.4-dev libpython3.4-dev # Make the interpreter of python3 have a symlink # if things didn't get set up this way. It really # shouldn't be there since we so agressively reset # ourselves but safety is safety. [ -e /usr/bin/python3 ] || ln -s /usr/bin/python3.4 /usr/bin/python3 } get_pip() { # Although python3.4 "ships with pip" the PPA doesn't. # So we need to do this ourselves. # Look at http://stackoverflow.com/questions/11268501/how-to-use-pip-with-python-3-x-alongside-python-2-x curl https://bootstrap.pypa.io/get-pip.py > /tmp/get-pip.py python3.4 /tmp/get-pip.py rm -f /tmp/get-pip.py # This will place pip8 on the system for 3.4 and # upgrade it for 2.7 if you have it sitting around # still pip -U pip } make_pip_wrapper() { # Alright we are so close. There's no pip3 anymore if you notice. # That's becaues the new *built-in* method works by invoking pip # within the version of python you want like this: # # python3.4 -m pip install # # "This is bunk" you say. "All my legacy shit will break". # Indeed. Let's just write a wrapper then. [ -e /usr/local/bin/pip3 ] && mv /usr/local/bin/pip3 /usr/local/bin/pip3.old echo 'python3.4 -m pip $*' > /usr/local/bin/pip3 chmod +x /usr/local/bin/pip3 }