Make virtual environments with different Python versions in Xubuntu 14.04

27 Mar 2017 ᛫ 3 min read


If you’re running Ubuntu, you should avoid upgrading or modifying the Python version that came with your system because doing so could lead to unwanted results, conflicts, and even system breakage. In the case of Xubuntu 14.04 (Trusty Tahr), the Python versions that come with it are 2.7.6 and 3.4.3.

Now, if you feel that these versions are outdated and you want to try the newer Python versions, the best course of action is to use virtual environments. Virtual environments allow you to sandbox multiple Python versions depending on your development needs so that you don’t have to upgrade or downgrade your system’s Python version. For python 2.7-3.4, virtualenvwrapper is probably your best option. From version 3.3 onwards, Python has included the venv module for creating virtual environments as part of its standard library.

I personally use virtualenvwrapper so that’s what I’m going to show you here. First of all, make sure the virtualenvwrapper is already installed in your machine then follow the steps below.

Install dependencies

Install the following dependencies if they aren’t already.

sudo apt-get install -y \
autotools-dev      \
blt-dev            \
build-essential    \
bzip2              \
dpkg-dev           \
g++-multilib       \
gcc-multilib       \
libbluetooth-dev   \
libbz2-dev         \
libexpat1-dev      \
libffi-dev         \
libffi6            \
libffi6-dbg        \
libgdbm-dev        \
libgpm2            \
libncursesw5-dev   \
libreadline-dev    \
libsqlite3-dev     \
libssl-dev         \
libtinfo-dev       \
mime-support       \
net-tools          \
netbase            \
python-crypto      \
python-dev         \
python-mox3        \
python-pil         \
python-pip         \
python-ply         \
python-setuptools  \
python-smbus       \
quilt              \
tk-dev             \

Download the Python version that you want


If you want to get Python 2.7.13 (the latest Python 2 version)


Unpack, configure, and compile

The line below will unpack the contents of the archive to a Python-2.7.13 directory.

tar xfz Python-2.7.13.tgz

Go to the directory and configure where you want to install the new Python version. Here we’ll install it in /usr/local/lib/python2.7.13.

cd Python-2.7.13/
./configure --prefix /usr/local/lib/python2.7.13 --enable-ipv6

Run make and make install.

sudo make install

Test if the Python version was compiled successfully

Remember where we installed our new Python version? Let’s check if the compiler will run.

Enter the following in your command line.


It should result in something similar below.

Python 2.7.13 (default, Mar 27 2017, 13:19:48)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.

Make a virtual environment using the version of Python you just installed.

mkvirtualenv --python=/location/where/you/installed/python <name-of-virtualenv>


mkvirtualenv --python=/usr/local/lib/python2.7.13/bin/python python2.7.13

Upon making the virtual environment, you will be able to immediately start working on it.

Test if the Python version in your virtual environment is correct.


should result in:

Python 2.7.13 (default, Mar 27 2017, 13:19:48)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.

From here you can start developing using the Python version of your virtual environment. Write code, download libraries, etc.

Additional stuff:

virtualenvwrapper has a lot of stuff that makes working with virtual environments easier. Some of these are:

To list the virtual environments on your machine


To work on a virtual environment

workon <name-of-virtualenv>

To create a virtual environment

mkvirtualenv <name-of-virtualenv>

This uses the default Python of your machine. See #5 above if you want to use a different Python version.

To remove/delete a virtual environment

rmvirtualenv <name-of-virtualenv>
comments powered by Disqus

You may also like:

ImportError - No module named resources_rc (QGIS Plugin Development) [SOLVED]

10 Apr 2017 ᛫ 1 min read

Adding images to the GUI of your custom QGIS 2.X plugin with Qt Designer

10 Apr 2017 ᛫ 2 min read

update-manager and update-notifier packages won't upgrade in Xubuntu 16.04 because of missing six module. [SOLVED]

06 Apr 2017 ᛫ 1 min read

Make a Python 3.6 virtual environment in Xubuntu 16.04 using venv

04 Apr 2017 ᛫ 2 min read

Create a bootable Windows 10 USB in Xubuntu 16.04 using mkusb

03 Apr 2017 ᛫ 1 min read

Support BNHR

If you find my website or any of the materials I share useful, you can consider donating to the cause below.

Donate and support BNHR


[email protected]

Creative Commons License
Except when explicitly stated otherwise, this work and its contents by Ben Hur S. Pintor is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Other works (software, source code, etc.) referenced in this website are under their own respective licenses.
This site is powered by Jekyll and hosted on Github (view source)