r/IPython • • Sep 18 '15

Using Python3.5 in Ubuntu - Trusty

If you haven't already made the switch by installing from the source, and you want to install Python 3.5 system wide, you can use the following steps to upgrade to Python using the fkrull/deadsnakes ppa.

Open a terminal window.

  • install Personal Package Archive: ppa:fkrull/deadsnakes

    • sudo add-apt-repository ppa:fkrull/deadsnakes

    • sudo apt-get update

  • install the following packages:

    • sudo apt-get install python3.5

    • sudo apt-get install python3.5-dev

    • sudo apt-get install libncurses5-dev

  • change python3 link to point to python3.5 instead of python3.4 (/usr/bin/)

    • sudo mv /usr/bin/python3 /usr/bin/python3-old

    • sudo ln -s /usr/bin/python3.5 /usr/bin/python3

  • install pip from https://pip.pypa.io/en/stable/installing/

  • install the following with pip3:

    • sudo pip3 install setuptools --upgrade

    • sudo pip3 install ipython[all]

  • change the python3 link back

    • sudo rm /usr/bin/python3

    • sudo mv /usr/bin/python3-old /usr/bin/python3

  • create python3.5 kernel

    • cp -R ~/.ipython/kernels/python3 ~/.ipython/kernels/python3.5

    • sed -i -- 's/3/3.5/g' ~/.ipython/kernels/python3.5/kernel.json

After your done you can check by creating a Python 3.5 kernel Notebook and entering the following:

import sys
sys.version_info

You should get the following response.

sys.version_info(major=3, minor=5, micro=0, releaselevel='final', serial=0)

*Edit: Reverted the default python3 to python3.4 but created a python3.5 kernel entry for the notebook. The reason for this is that changing the default python3 to python3.5 broke the apt-get updating process.

7 Upvotes

3 comments sorted by

View all comments

2

u/waspbr Sep 20 '15

Easier way: Install pyenv

1

u/NomadNella Sep 20 '15

Thanks for pointing that out. I think my work flow is a little different than normal and I was just sharing if anyone else wanted to install system wide. My work is currently changing, so I will probably make the switch before too long.