Take the 2-minute tour ×

I have installed and configured python from online tutorials, python books, and other various sources in the past only to find myself digging through forums when things go wrong and piecing various information together to try and reach my objective. Which is a clean installation/configuration of python 3.X.X that does not interfere with the system's default interpreter, has pip, easy install, distribute tools, and virtualenv all properly configured and working; can be used side-by-side with the system's python interpreter, is installed in the /opt/ directory (the proper location), is named clearly in the /opt/ directory (e.g. python3.3.0, python3.3.1, python3.3.2), and can be called from the terminal window without using alias (i.e. the path is setup and working). This is a lot of criteria, but is the setup I'm looking for. When following online tutorials, I can typically achieve a few of these, but never all of them.

The closest tutorial I have found so far is here (How to install Python 3.3?), but it still doesn't provide enough clarification or has broken steps. For example, the answer with the most votes (by Sergey and minerz029) has the following issues:

  • Does not explain how to setup pip, easy install, distribute tools, and virtualenv. It appears impossible with those steps because they do not include setting up the proper dependencies before compiling to get distribute tools (necessary to get pip) prior to compiling (as indicated here (http://stackoverflow.com/questions/18833442/installing-distribute-for-python-3-3). But then when trying to follow the second link, openssl-devel doesnt seem available from apt-get.

  • Does not setup the python path but rather uses a systemlink.

All the tutorials I follow start a chain reaction in going from forum to forum with no clear answer because everyone uses different steps, commands, methodologies etc. and often leave out key points that start the hunt all over again. Can anyone take a look at the first link and explain how to get pip, easy_install working? I have also followed the second author's instructions (i.e. “Boolean”) but his steps break at step 3 and appears to exclude key points between steps 2 and 3 in switching directories.

share|improve this question
Do you want your /opt installation to be a virtualenv? –  minerz029 Jan 17 at 7:34
I believe so. My understanding is that it will eliminate the breakage of each python3.X.X's installation dependencies. But I'm still learning python. –  Kryptos Jan 17 at 7:42

1 Answer 1

up vote 2 down vote accepted

These steps will create a Python 3.3 virtualenv in a /opt subdirectory:

  1. Install Pip and virtualenv on your system Python installation.

    sudo apt-get install python-pip
    sudo -H pip install virtualenv
  2. Run this command (see notes below):

    sudo -H virtualenv /opt/python_custom -p python3
    • Replace /opt/python_custom with the path you would like to install to.
    • Replace python3 with the interpreter which will be used, e.g.: python2, python3.3 or others.
  3. If you want to operate on this Python installation, you will need to run this command first:

    source /opt/<PYTHON>/bin/activate

    (replace <PYTHON> with the path from above)

    Your shell prompt will change to reflect the current virtualenv.

  4. You can then use sudo pip to install whichever packages you would like, e.g.:

    sudo pip install setuptools
    sudo pip install distribute

Note: To use this Python in your scripts, specify the #! line to be the virtualenv interpreter, e.g.:


Note: You'll need to use sudo when changing the virtualenv (e.g.: by installing a package with pip) because it is installed into /opt, which is owned by root.

share|improve this answer
I was not able to get past the first command. Here is the result of my "uname -a" Linux kryptos-Darkfleet 3.5.0-18-generic #29-Ubuntu SMP Thu Oct 25 07:26:14 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux. I'm running linux mint 13 LTS –  Kryptos Jan 17 at 7:55
kryptos@kryptos-Darkfleet ~ $ sudo apt-get install python3-pip Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package python3-pip kryptos@kryptos-Darkfleet ~ $ –  Kryptos Jan 17 at 7:58
I checked my sources list and also here: packages.ubuntu.com/… . I'm still investigating... It doesnt look like pip3 is an available package here: packages.ubuntu.com/… –  Kryptos Jan 17 at 8:26
The package is missing for precise and no longer available. It is available for other versions. Not sure how to report or fix it. packages.ubuntu.com/… –  Kryptos Jan 17 at 8:38
In your step, 2, can "python3" be replaced with "python" (the system default python2.X) and if so, will this setup still work with virtual python3 if I never ran apt-get install python3? I'm trying to clean up the mess I made that night you helped me by following your instructions on a brand new install and ran into issues. askubuntu.com/questions/408192/how-to-install-python-3-x-x –  Kryptos Jan 20 at 13:50

Your Answer


