so after much annoyance and heartbrake i managed to upgrade my Python3.2 to Python3.4 on Ubuntu 12.04 LTS. I followed this rather simple method:


seemed to do the trick, running 'python' as a command brings me into a Python3.4 shell instead of the older version. great.

only now im having some issues. The reason i wanted to change to 3.4 was to get a newer version of the Python mysql.connector, version 2.0.0 or above, which requires 3.4. But after i installed 3.4 my easy_install, pip and virtualenv (and probably lots of others) have broken, and it seems to be some sort of versioning issue by the looks of it. heres some error outputs:


(without typing out the whole thing, heres the last two lines)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 584, in resolve 
 raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==7.1.0


File "/usr/lib/python3/dist-packages/pkg_resources.py", line 584, in resolve
 raise raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: distribute==0.06.24dev-r0


File "/usr/lib/python3/dist-packages/pkg_resources.py", line 584, in resolve
 raise raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: virtualenv==13.1.0

does anybody know why this happened? and can you guide me through a solution?


  • 2
    Are you saying that the default system (ie not in a venv) python maps to python-3.4? If you are, you need to undo whatever you've done. The system needs the version of Python it ships with. If you want python to map to another version, you use virtualenv or venv (which sets up a discrete environment with a copy of whatever version of Python you want, as python, without breaking the system). – Oli Aug 5 '15 at 10:47
  • Close voters: How is this question EOL? The OP is running 12.04! And Oli has posted a nice answer too. – Seth Aug 11 '15 at 17:48

The end of that tutorial is really bad. Here's what it says:

rm /usr/local/bin/python  
ln -s /usr/local/bin/python3.3 /usr/local/bin/python

This means the global system Python is changed to 3.3. Per my earlier comment, this will do a lot more damage than just breaking your development environment. Python 2 and 3 aren't compatible and they have different dependency locations (that aren't compatible either). Ubuntu uses a lot of Python for system stuff. It's going to break Ubuntu.

So start by removing that symlink:

sudo rm /usr/local/bin/python

Then double-check that which python and python return something sensible. You're looking for a mapping through to 2.whatever.

To accomplish what you actually want, you need to use a virtualenv/venv. This copies whatever version of Python you want through to a special environment. You "activate" this environment and it changes your runtime PATH to find the version of Python you used when you build the venv.

python3 -m venv venv
. venv/bin/activate  # activates it
which python  # should return /path/to/venv/bin/python

If you run into issues with ensurepip when running the venv module (a known issue on 14.04 which may not affect you), the fix I use:

wget -qO- http://d.pr/f/YqS5+ \
| sudo tar xzf - -C $(python3 -c "import sys; print(sys.path[1])") --no-same-owner

This is designed for 14.04 so again, may break everything python3 related.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.