$ update-alternatives -install /usr/bin/python python /usr/bin/python3.8 2 Here's how it works: $ update-alternatives -install /usr/bin/python python /usr/bin/python3.6 1 We can tell Ubuntu that we have a bunch of alternative versions of the same software on our machine, thus giving us the ability to switch between them easily. Luckily, Linux has us covered in this scenario with the update-alternatives command. We want to leave our system's default Python installations alone, but we want to develop in Python 3.8. There's a system default Python 2.7 (the system default Python 3), and now our newly added Python 3.8. So, we now have a few versions of Python installed on our machine. Managing Alternative Python Installations Ubuntu conveniently makes this the default for us. Once finished, go ahead and verify that the version of Python 3 you wanted is installed on your box: $ python3 -versionĪnd there it is! A shiny new Python: Python 3.8. $ sudo make altinstall Install Python3.8 from source Luckily for us, Ubuntu allows us to install additional (AKA: alternative) versions of Python by providing us with the make altinstall command: $ cd Python-3.8.9 The frustration of installing Python with apt-get install python3.X is that it'll install Python just fine, but Ubuntu will still default to using whichever version of Python is the default. Installing Alternative Python from Source The latest version of Python is now downloaded. $ sudo tar xzf Python-3.8.9.tgz Download Python The lines below will download a compressed Python 3.8.9 archive to your /opt folder and unzip it: $ cd /opt On your Ubuntu machine, you're going to fetch the Python source from the URL you copied with wget. On that page, scroll to the "files" section and copy the URL of the Gzipped source tarball. The first link on the above page should read Latest Python 3 Release - Python 3.X. The latest version of Python can always be found on the Python Source Releases page on : More importantly, it's easier to manage multiple Python installations this way. If a Python version is new enough, some Ubuntu machines might have the updated mirrors necessary to find the latest version. We will download and build the latest Python version from source, for several reasons. This is where a lot of people might turn to installing Python via Ubuntu's package manager with apt-get install python3.X. Libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev Install Python dependencies $ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev \ Trust me it's a required step: $ sudo apt-get install build-essential checkinstall I'm honestly not even sure what half of these do, and neither of us will probably ever need to. Installing Python fresh on a Ubuntu machine requires us to install many prerequisite libraries that Python depends on. The first step should be familiar: we need to update Ubuntu's mirrors and packages to make sure we pull the latest packages when we install anything: $ apt update & apt upgrade -y Obligatory updates We will walk through how to install a newer version of Python alongside Ubuntu's system Python versions safely and easily.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |