Created
August 15, 2019 07:26
-
-
Save thekitp/bc8b8f98cb76188049dde5a55dfddf60 to your computer and use it in GitHub Desktop.
Installing Python 3.7 from source on Ubuntu 18.04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 | |
| ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment