{"id":6927,"date":"2017-07-06T16:40:27","date_gmt":"2017-07-06T16:40:27","guid":{"rendered":"http:\/\/ubuntuhandbook.org\/?p=6927"},"modified":"2017-12-23T16:56:02","modified_gmt":"2017-12-23T16:56:02","slug":"install-python-3-6-1-in-ubuntu-16-04-lts","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2017\/07\/install-python-3-6-1-in-ubuntu-16-04-lts\/","title":{"rendered":"How to Install Python 3.6.1 in Ubuntu 16.04 LTS"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/07\/python-icon245.png\" alt=\"\" width=\"245\" height=\"250\" class=\"alignleft size-full wp-image-6928\" \/><\/p>\n<p>This quick tutorial is going to show you how to install the latest Python 3.6.1 in Ubuntu 16.04 LTS via PPA.<\/p>\n<p>Ubuntu 16.04 comes with both Python 2.7 and Python 3.5 by default. You can install Python 3.6 along with them via a <a href=\"https:\/\/launchpad.net\/~jonathonf\/+archive\/ubuntu\/python-3.6\" target=\"_blank\">third-party PPA<\/a> by doing following steps:<\/p>\n<p><b>1.<\/b> Open terminal via Ctrl+Alt+T or searching for &#8220;Terminal&#8221; from app launcher. When it opens, run command to add the PPA:<\/p>\n<pre style=\"border:none;\">sudo add-apt-repository ppa:jonathonf\/python-3.6<\/pre>\n<p><i>Type in your password (no visual feedback due to security reason) when it asks and hit Enter.<\/i><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/07\/python-3.6-ppa-600x84.jpg\" alt=\"\" width=\"600\" height=\"84\" class=\"aligncenter size-large wp-image-6929\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/07\/python-3.6-ppa-600x84.jpg 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/07\/python-3.6-ppa-450x63.jpg 450w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/07\/python-3.6-ppa.jpg 742w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><b>2.<\/b> Then check updates and install Python 3.6 via commands:<\/p>\n<pre style=\"border:none;\">sudo apt-get update\r\n\r\nsudo apt-get install python3.6<\/pre>\n<p>Now you have three Python versions, use <code>python<\/code> command for version 2.7, <code>python3<\/code> for version 3.5, and\/or <code>python3.6<\/code> for version 3.6.1.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/07\/python-versions-600x143.jpg\" alt=\"\" width=\"600\" height=\"143\" class=\"aligncenter size-large wp-image-6930\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/07\/python-versions-600x143.jpg 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/07\/python-versions-450x107.jpg 450w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/07\/python-versions.jpg 742w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><b>3.<\/b> To make <code>python3<\/code> use the new installed python 3.6 instead of the default 3.5 release, run following 2 commands:<\/p>\n<pre style=\"border:none;\">sudo update-alternatives --install \/usr\/bin\/python3 python3 \/usr\/bin\/python3.5 1\r\n\r\nsudo update-alternatives --install \/usr\/bin\/python3 python3 \/usr\/bin\/python3.6 2<\/pre>\n<p>Finally switch between the two python versions for <code>python3<\/code> via command:<\/p>\n<pre style=\"border:None;\">sudo update-alternatives --config python3<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/07\/python3-alternative-600x179.jpg\" alt=\"\" width=\"600\" height=\"179\" class=\"aligncenter size-large wp-image-6931\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/07\/python3-alternative-600x179.jpg 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/07\/python3-alternative-450x135.jpg 450w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/07\/python3-alternative.jpg 739w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>After selecting version 3.6:<\/p>\n<pre style=\"border:none;\">python3 -V<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/07\/python3-3.6-600x75.jpg\" alt=\"\" width=\"600\" height=\"75\" class=\"aligncenter size-large wp-image-6932\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/07\/python3-3.6-600x75.jpg 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/07\/python3-3.6-450x56.jpg 450w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/07\/python3-3.6.jpg 743w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><b>UPDATE:<\/b> due to this <a href=\"https:\/\/bugs.launchpad.net\/ubuntu\/+source\/python3.6\/+bug\/1631367\" target=\"_blank\">bug<\/a>, gnome-terminal won&#8217;t launch after step 3, a workaround is running following commands to recreate the symlink:<\/p>\n<pre style=\"border:None;\">sudo rm \/usr\/bin\/python3\r\n\r\nsudo ln -s python3.5 \/usr\/bin\/python3<\/pre>","protected":false},"excerpt":{"rendered":"<p>This quick tutorial is going to show you how to install the latest Python 3.6.1 in Ubuntu 16.04 LTS via PPA. Ubuntu 16.04 comes with both Python 2.7 and Python 3.5 by default. You can install Python 3.6 along with them via a third-party PPA by doing following steps: 1. Open terminal via Ctrl+Alt+T or [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[1470,960],"class_list":["post-6927","post","type-post","status-publish","format-standard","hentry","category-howtos","tag-python-3-6","tag-python-ide"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/6927","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=6927"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/6927\/revisions"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=6927"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=6927"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=6927"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}