Python 3.6.10 is the latest stable version at the time of writing of tutorial. This Python version is available to download and install. This article will help you to install Python 3.6.10 on Ubuntu and Linuxmint operating system. To know more about this version visit Python official website.
Step 1 – Prerequsities
Use the following command to install prerequisites for Python before proceeding to the next steps.
sudo apt-get install build-essential checkinstall sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
Step 2 – Download Python 3.6
Download Python using following command from python official site. You can also download the latest version in place of specified below.
cd /usr/src sudo wget https://www.python.org/ftp/python/3.6.10/Python-3.6.10.tgz
Now extract the downloaded package.
sudo tar xzf Python-3.6.10.tgz
Step 3 – Compile Python Source
Now use below set of commands to compile Python source code on your system. We use --enable-optimizations
option with configure command to enable additional supports like SSL, bz2 support. With make command altinstall
, to install it as separate Python, This will not overwrite the existing installation.
cd Python-3.6.10 sudo ./configure --enable-optimizations sudo make altinstall
Step 4 – Check the Python Version
Finally, you have successfully installed Python 3.6 on your system. Let’s check the version installed of python using the below command.
python3.6 -V Python 3.6.10
This will also configure PIP for you to install Python modules.
pip3.6 -V pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
56 Comments
Thanks. This helped me.
Am getting the following error after following all instructions and successful install:
mike@Mike-Inspiron-Mint:/usr/src/Python-3.6.10$ pip3.6 -V
bash: pip3.6: command not found
Please advise….thanks!!
Thank you , excellent instruction
Thanks god work!!
Thank you, it works well!
Does this work on Raspberry Pi 3 B+?
I found the following error:
The directory ‘/home/haftom/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
The directory ‘/home/haftom/.cache/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
Did you ever find a resolution to this?
thanks a lot bro . i just didn’t know who i would start
Thanks a bunch! Worked like a charm
It was helpfully. Very easy. First, I installed Python3.6.1 from cd installer on my pc ,ubuntu 16.04, then process stopped . There were some errors.
I tried using this tutorial . Works !
Thanks a lot
I can’t thank you enough, this was very helpful, god bless!
I have installed python 3.6.6 successfully on ubuntu 14.04 but PyCharm is not detecting 3.6 as an interpreter.
Can you please help me with same?
Thank’s very much brother!!!
Good luck!!
Hi Rahul than you for sharing. I setup successfully python 3.6.6 on my pc, because of you , but I can not setup python idle 3.6.6 . When I try setup idle , it was for python 3.6.6 . How I can fix this problem.
Just tried this but it fails
Checking for python version >= 2.7.0 : 3.6.4
python-config : /usr/local/bin/python3.6m-config
Asking python-config for pyembed ‘–cflags –libs –ldflags’ flags : yes
Testing pyembed configuration : yes
Asking python-config for pyext ‘–cflags –libs –ldflags’ flags : yes
Testing pyext configuration : Could not build python extensions
The configuration failed
(complete log in /tmp/pip-build-k_6fcvg_/wxPython/build/waf/3.6/gtk3/config.log)
Command ‘”/usr/local/bin/python3.6″ /tmp/pip-build-k_6fcvg_/wxPython/bin/waf-2.0.7 –wx_config=/tmp/pip-build-k_6fcvg_/wxPython/build/wxbld/gtk3/wx-config –gtk3 –python=”/usr/local/bin/python3.6″ –out=build/waf/3.6/gtk3 configure build ‘ failed with exit code 1.
Finished command: build_py (0.782s)
Finished command: build (3m45.45s)
Command ‘”/usr/local/bin/python3.6″ -u build.py build’ failed with exit code 1.
Make sure you update pip3.6 with sudo -H pip3.6 install –upgrade pip
Nice but did not mention how to run python after installation
just type “python3.6” after successfully installing it.
voila..!!
Really good man!
great, easy & happy intall.
thanks a lot !
Hi. i have tried this. Now I have python 2.7, 3.6 and 3.6 in my system. but my Pycharm cannot find the 3.6 in selecting interpreter settings. How can I fix this?
Thanks
Thanks brother
great article. quick question: why skip ‘make’ before run ‘make altinstall’?
Thank you bro.
Thanks for the article. I had been facing the error described at this link: https://stackoverflow.com/questions/41328451/ssl-module-in-python-is-not-available-when-installing-package-with-pip3
Your comment there brought me to your article. And I tried reinstallation after adding the dependencies you had mentioned. It works fine now. Thanks Again 🙂
Having installed python3.6.4, how do i uninstall it?
Okay, this is legitimately the best Linux Mint guide I’ve seen on this topic. I never realized this website had actual working installation guides.
Thanks. Seems to work on Linux mint 18.3
Alias existing:
$ python
Refers to v 2.712
$ python3
Refers to v 3.52
Is it safe to replace these aliases with the latest Python version or will this break a lot of things in linux?
Might want to try “sudo make -j altinstall” … The -j option tells make to use all your CPU cores, so it builds faster if you have more than one core.
Nice to have instructions that actually work for ones! Thank you very much
Where’d you find those? I think installing from source DID work for me once…but I won’t swear to it.
thanks for your text!
Very helpful article, thanks
you should add this to the list of dependencies in step 1 so that lzma package works. I found that python 3.6.3 won’t have lzma support without this. I’m on ubuntu 17.04 btw.
sudo apt-get install liblzma-dev
Thanks 😀 It works fine for 3.6.4, replacing “Python-3.6.3” to “Python-3.6.4”
Followed all the instructions above , had no errors. Thanks you.
after completion of all the commands how to find my python folder like where it is installed
how to remove python 3.6 ??wu=ithout effecting 2.7, 3.2
how did you get the certification? what exam should i write? please share it with me. thank you. 🙂
It works with a little modifications. Thx a lot!
Hi Paul,
What modifications you did? Please share with our readers.
The latest release is now 3.6.2 and the instructions given above, using the URL you outline but replacing “3.6.0” with “3.6.2” does not work. The error for both “3.6.0” and “3.6.2” is “Python 3.6.x – Permission denied. I did download 3.6.2 and it is in my download folder but I am unable to copy or move it to /usr/src. I am new to Linux so it is undoutedly my inexperience that limits me but I would like to use Python on LinuxMint. Thanks.
Hi Don, Use sudo with cp command to copy files.
Thanks. I was using the right click copy & paste to do it. The command line worked. Following the rest of the commands above it extracted and at the end of the ./configure task it indicated that if wanted a release build with all stable optimizations active (PGO, etc) I should run “./configure –enable-optimizations” which I did.
After running the “sudo make altinstall” command I ran the “Python-3.6 -V” command and got “Command not found”. I cannot find v3.6.2 on the computer. I do find v 2.7.11 and v 3.5 .2. I also find “Idle” for v 2.7.
I’ll give up on this for now and learn more about LinuxMint before trying again. I have previous experience in programming but trying to get Python 3.6.2 has me frustrated. Thanks.
You might have already figured this out, but in case you haven’t – your comment uses an incorrect binary name. You should be able to use the new version by running “python3.6” (so your version check would be “python3.6 -V”, not “Python-3.6 -V”). The rest of this comment is optional; only read if you want a pedantic breakdown of how python versions are managed.
To paraphrase from the Python-3.6.2/README.rst file:
>All files and installed using “sudo make altinstall” contain the major and minor version and can thus live side-by-side: “${prefix}/bin/pythonX.Y”.
>”sudo make install” also creates the symbolic link “${prefix}/bin/python3” which points to “${prefix}/bin/pythonX.Y”.
An example to illustrate what this means:
Python 2.7.6 and Python 3.4.3 are installed by default on Ubuntu 14.04. If you run “python”, you enter a Python 2.7.6 prompt – because there is a symlink called “python” pointing to a symlink called “python2” pointing to a binary called “python2.7”. Running “python2” gives the same result, of course. If you run “python3”, you enter a Python 3.4.3 prompt – because there is a symlink called “python3” pointing to a binary called “python3.4”.
If you follow this page’s instructions and use “make altinstall”, a new binary will be added called “python3.6” Running “python3.6” gives 3.6.2; running “python3.4” gives 3.4.3; running “python3” gives 3.4.3 (because of the symlink).
If instead you use “make install”, the “python3.6” binary is created, same as before – but in ADDITION to this, the “python3” symlink will be overwritten with one that points to “python3.6”. So running “python3.6” and “python3.4” has the same behavior as before, but now running “python3” gives 3.6.2.
By default in Ubuntu (and so probably in Linux Mint) the system python links/binaries are in the /usr/bin folder, and it seems like when a user installs Python from source, by default the links/binaries are put in /usr/local/bin.
So if you’ve used the defaults, you can find most of what you have by running this command: “find /usr/bin /usr/local/bin -iname ‘python*’ -ls” (i.e., find everything in /usr/bin and /usr/local/bin whose name starts with “python” and print the results).
Also works fine on Raspian Jessie 4.9.24 – thanks for sharing.
when iam installing python3.6.0,i wrote the command for downloading python version $ cd/usr/src but it showing that such directory was not existing,so what can i do
put a space after the “cd” command….you have “cd/usr/src” when it should be “cd /usr/src” – pay close attention to syntax as it will trip you up all the time….
Hi. I needed to do: sudo wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz, then I untar but the terminal is not allowing me to cd to Python-3.6.0/ !!! “Permission denied”. If I try: sudo cd Python-3.6.0/ then “sudo: cd: command not found” 🙁 What can I do?
I had the same problem too. What I did was, I used “sudo -s”, and then I was able
to cd to Python-3.6.0 .
Hi
How i can use python 3.6 as default in Ubuntu 16.04 ?
using this ppa for ubuntu and derivates 14.04/16.04:
ppa:jonathonf/python-3.6
thanks 🙂
Hi Rahul,
Python 2.7 was pre -installed on my laptop. I use Ubuntu 16.04
I downloaded 3.6.0 and followed the steps mentioned by you.
I encountered no error in any of the steps.
Yet the version still shows 2.7.
Help needed. Thanks
Aikya
Hi Aikya,
The command will be as
python3.6
not onlypython