How to upgrade to python 3.7 on ubuntu 18.10
Ubuntu 18.10 ships with python 3.6.7, here is how to install python 3.7 and configure it as the default version of python
Before getting started, run the following command to see what version of python3 you are running.
python3 -V
Python 3.6.7
NOTE: Some comments below have warned that using update-alternatives
to switch from python 3.6 to python 3.7 will cause problems for some (Ubuntu Desktop) GUI applications that are linked to python 3.6. This guide is targeted at non-graphical ubuntu servers and works great as far as I’ve tested.
You can still install and use python 3.7 on Ubuntu Desktop machine just skip the update-alternatives steps below. To use 3.7 instead of 3.6 just execute python3.7 directly, create a virtualenv or use pipenv.
Install Python 3.7
Steps to install python3.7 and configure it as the default python3 interpreter.
- Install the python3.7 package using apt-get
sudo apt-get install python3.7
- Add python3.6 & python3.7 to update-alternatives
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2
- Update python3 to point to python3.7
sudo update-alternatives --config python3
Enter 2 for python3.7 - Test the version of python
python3 -V
Python 3.7.1
Now you should have the latest stable version of python running on your Ubuntu linux server. Leave a comment below and checkout my other linux tutorials.
DigitalOcean offers one-click deployment of popular applications such as WordPress, Django, MongoDB, Docker, and even preconfigured Kubernetes Clusters. Deploy your next app in seconds. Get $100 in cloud credits from DigitalOcean
Ad Notice I will receive a small commission that helps support this blog at no cost to you.
36 Replies to “How to upgrade to python 3.7 on ubuntu 18.10”
Thanks a million for this. This really worked.
Man you’re awesome. Thank you for this. I’m new to Ubuntu and feel like posts like these are invaluable to me. I tried installing with instructions from python’s site and kept getting errors. Maybe because of the version number? I don’t know, this worked though and I’m grateful for it.
THANK YOU … I did not know that Ubuntu comes with python to begin with.
THANK YOU
Obrigado!
After updating python3 to point to python3.7, I am getting ModuleNotFoundError using pip3, how should I also install pip3 for python3.7?
If you update Python to latest version (3.7.3 at the moment) on Ubuntu 18, your native terminal won’t load. This article is helpful but not completed!
Although I installed Python 3.7.1 my native terminal stopped working and my computer could not receive updates so I had to return Python 3.6 as the default python3 interpreter.
yes! Terminal has a fit if the python3 symlink points to python 3.7. Why is this? Why does ubuntu 18.04 REQUIRE that the symlink, python3, point to python3.6? Is python 3,7 THAT different??
Using update-alternatives to change python3 is not advisable a Ubuntu Desktop 18.10. As far as I’ve tested it works on non-gui ubuntu server installs.
If you’ve already “broken” your native terminal by setting your update-alternatives to 3.7, try this:
-Ctrl-Alt-F1 (this will switch you into the virtual console)
-Plug in your system username and password
-Enter the following: sudo update-alternatives –config python3
-Select the option 1, for python 3.6
-Ctrl-alt-F7 to return back to the GUI
Your native terminal should work after this :-)
THANKS
It’s not ideal, but for emergency access (e.g. to fix /usr/bin/python3) you can still use xterm
That is great! Thx
Concise and works well – thanks!
After doing this, python3 worked. However, I could not use pip anymore. I had to revert.
This is a fantastic post. Thank you. It worked as you indicated.
You are very welcome, I’m glad it helped you out!
Thanks for the update-alternatives bit!
Please take down this article or at least amend it, this solution breaks terminal and the software update because it messes with default ubuntu config, check stackoverflow.
This problem you describe is only on full gui installs of ubuntu but
update-alternatives
works great for non-gui servers. I have added a warning note at the top of the article.great!
thank you
Thanks so much you helped me.
You’r awesome! Thx alot for such an easy instruction.
Thanks. worked.
I did this without reading the note at the top and it really screwed me up. Hopefully people don’t do the same thing I did!
On My Linux Mint 19.1 Cinnamon this messed up Cinnamon completely. I guess default Python 3.6 is required here. I resolved it by starting cinnamon in “software rendering mode” where it seems to work, to find command again: ‘sudo update-alternatives –config python3’ and selected 3.6 as manual default. I guess now when you know what to do you can also press CTRL+ALT+F1 to go to shell and type it there aftre login. Then sudo reboot.
The option “–config python3” can never work. It must be “-–config python3”, as all parameters in Linux which are longer than 1 char must be typed with two dashes!
But anyway, it was not found on my Linux Mint KDE 18.3 machine.
To be honest, this guide for python upgrade is the best for linux. Thank you for sharing!
Worked for me as well, Thanks for sharing this
thank you sir
Worked for my Ubuntu… Thanks!
As pedroig said on April 3rd, update-alternatives break pip3 (no module found error). The site-packages reflect correct info, pip3 –version is correct, but imports fail.
Please address this concern.
Thanks man !!
Thanks