Xubuntu 16.04 comes packaged with Python 3.5.2. As is standard practice, it’s not advisable to update or change the Python version of your distribution lest you risk possible problems in your system. One of the better options if you want to use different python versions in your machine is to use virtual environments. Since version 3.4, Python has come packaged with venv – a library for making virtual environments. This post will show you how to install Python 3.6.1 in Xubuntu 16.04 and use venv to create a virtual environment running Python 3.6.1.
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 \ zlib1g-dev
The line below will unpack the contents of the archive to a Python-3.6.1 directory.
tar xfz Python-3.6.1.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/python3.6.1.
cd Python-3.6.1/ ./configure --prefix /usr/local/lib/python3.6.1 --enable-ipv6
Run make and make install.
sudo make install
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 3.6.1 (default, Apr 4 2017, 12:20:28) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>>
/usr/local/lib/python3.6.1/bin/python3 -m venv <location-of-virtualenv>
I tend to put all my virtual environments in a single directory. I recommend having something like a .venvs directory for that purpose.
/usr/local/lib/python3.6.1/bin/python3 -m venv ~/.venvs/python3.6.1
From here you can start developing using the Python version of your virtual environment. Write code, download libraries, etc.
If you find my website or any of the materials I share useful, you can consider donating to the cause below.
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)