Skip to content

Instantly share code, notes, and snippets.

@findmory
Forked from dschep/raspbian-python3.6.rst
Last active August 20, 2018 19:38
Show Gist options
  • Save findmory/04099381926e99c473c59888c78c09d4 to your computer and use it in GitHub Desktop.
Save findmory/04099381926e99c473c59888c78c09d4 to your computer and use it in GitHub Desktop.
Installing Python 3.7 on Raspbian

Installing Python 3.7 on Raspbian

As of August 2018, Raspbian does not yet include the latest Python release, Python 3.7. This means we will have to build it ourselves, and here is how to do it.

  1. Install the required build-tools (some might already be installed on your system).

    $ sudo apt-get update
    $ sudo apt-get install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev libffi-dev

    If one of the packages cannot be found, try a newer version number (e.g. libdb5.4-dev instead of libdb5.3-dev).

  2. Download and install Python 3.7. When downloading the source code, select the most recent release of Python 3.7, available on the official site. Adjust the file names accordingly.

    $ wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
    $ tar xf Python-3.7.0.tar.xz
    $ cd Python-3.7.0
    $ ./configure
    $ make
    $ sudo make altinstall
  3. Optionally: Delete the source code and uninstall the previously installed packages. When uninstalling the packages, make sure you only remove those that were not previously installed on your system. Also, remember to adjust version numbers if necesarry.

    $ sudo rm -r Python-3.7.0
    $ rm Python-3.7.0.tar.xz
    $ sudo apt-get --purge remove build-essential tk-dev
    $ sudo apt-get --purge remove libncurses5-dev libncursesw5-dev libreadline6-dev
    $ sudo apt-get --purge remove libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev
    $ sudo apt-get --purge remove libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev
    $ sudo apt-get autoremove
    $ sudo apt-get clean
  4. To get pip3.7 working you will need to do the following

    $ sudo rm /usr/bin/lsb_release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment