Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thekitp/bc8b8f98cb76188049dde5a55dfddf60 to your computer and use it in GitHub Desktop.
Save thekitp/bc8b8f98cb76188049dde5a55dfddf60 to your computer and use it in GitHub Desktop.

Revisions

  1. @jerblack jerblack renamed this gist Jun 30, 2018. 1 changed file with 0 additions and 0 deletions.
  2. @jerblack jerblack created this gist Jun 30, 2018.
    31 changes: 31 additions & 0 deletions install.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    # Installing Python 3.7 from source on Ubuntu 18.04

    ```bash
    # update system
    sudo apt update && sudo apt upgrade -y

    # install build tools and python prerequisites
    sudo apt install build-essential libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev libffi-dev

    # download and extract python
    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

    # build python
    ./configure --enable-optimizations
    # 'make -j <x>' enables parallel execution of <x> make recipes simultaneously
    sudo make -j 8
    # altinstall does not alter original system python install
    sudo make altinstall

    # run python3.7 when you type python3
    sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.7 1
    sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
    # run below and select python3.7 from the list
    sudo update-alternatives --config python3

    # or create a shortcut
    sudo ln -s /usr/local/bin/python3.7 /usr/bin/py

    ```