
{"id":43244,"date":"2022-10-25T15:13:21","date_gmt":"2022-10-25T15:13:21","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=43244"},"modified":"2022-10-28T07:46:32","modified_gmt":"2022-10-28T07:46:32","slug":"python-3-11-released-how-install-ubuntu","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2022\/10\/python-3-11-released-how-install-ubuntu\/","title":{"rendered":"Python 3.11 Released! How to Install in Ubuntu 22.04 | 20.04 | 22.10"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/10\/python-feature-icon.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-34796\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/10\/python-feature-icon-250x250.png\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/10\/python-feature-icon-250x250.png 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/10\/python-feature-icon-300x300.png 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/10\/python-feature-icon-600x600.png 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/10\/python-feature-icon-768x768.png 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/10\/python-feature-icon.png 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>The popular Python programming language released version 3.11 today. Here&#8217;s the new features and how to install guide for all current Ubuntu releases.<\/p>\n<p><a href=\"https:\/\/docs.python.org\/3.11\/whatsnew\/3.11.html\" target=\"_blank\" rel=\"noopener\">Python 3.11<\/a> claimed to be 10-60% faster than the previous 3.10, and features:<\/p>\n<ul>\n<li><b>Exception Groups<\/b> and <b>except*<\/b> to raise and handle multiple unrelated exceptions simultaneously.<\/li>\n<li>Add <code>add_note()<\/code> method to BaseException to enrich exceptions.<\/li>\n<li>Add the <code>tomllib<\/code> module to the standard library for parsing TOML<\/li>\n<li>Point to exact expression that caused error when printing tracebacks.<\/li>\n<li>New -P command line option and PYTHONSAFEPATH environment variable<\/li>\n<li>Add TypeVarTuple, enabling parameterisation with an arbitrary number of types<\/li>\n<li><code>Required[]<\/code> and <code>NotRequired[]<\/code> to mark whether individual TypedDict items must be present.<\/li>\n<li>Add <code>Self<\/code> to annotate methods that return an instance of their class<\/li>\n<li><code>LiteralString<\/code> to accept arbitrary literal string types, such as <code>Literal[\"foo\"]<\/code> or <code>Literal[\"bar\"]<\/code>.<\/li>\n<li><code>dataclass_transform<\/code> to decorate a class, metaclass, or a function that is itself a decorator.<\/li>\n<li>Removed Py_UNICODE encoder APIs<\/li>\n<li>Macros converted to static inline functions<\/li>\n<li>Many legacy standard library modules deprecated and to be removed in Python 3.13<\/li>\n<\/ul>\n<h3>How to Install Python 3.11 in Ubuntu<\/h3>\n<p>For <strong>Ubuntu 22.04, Ubuntu 20.04, Ubuntu 18.04<\/strong>, and their derivatives, such as Linux Mint, there&#8217;s a popular <a href=\"https:\/\/launchpad.net\/~deadsnakes\/+archive\/ubuntu\/ppa\" target=\"_blank\" rel=\"noopener\">Deadsnakes PPA <\/a> maintains the packages for Python 3.11 as well as other Python versions.<\/p>\n<p><strong>NOTE: The PPA does not support Ubuntu 22.10. You may follow the bottom link to build it from source tarball.<\/strong><\/p>\n<p>1. First, press <b>Ctrl+Alt+T<\/b> on keyboard to open terminal. When it opens, run command to add the PPA:<\/p>\n<pre>sudo add-apt-repository ppa:deadsnakes\/ppa<\/pre>\n<p><i>Type user password when it asks (no asterisk feedback) and hit Enter to continue<\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/deadsnake-ppa-jammy.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-43245\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/deadsnake-ppa-jammy-600x262.webp\" alt=\"\" width=\"600\" height=\"262\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/deadsnake-ppa-jammy-600x262.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/deadsnake-ppa-jammy-300x131.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/deadsnake-ppa-jammy-768x335.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/deadsnake-ppa-jammy.webp 780w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>2. Then refresh package cache via command below, though it&#8217;s done automatically in Ubuntu 20.04+:<\/p>\n<pre>sudo apt update<\/pre>\n<p>3. Finally, install python 3.11 via command:<\/p>\n<pre>sudo apt install python3.11<\/pre>\n<p>Or replace <code>python3.11<\/code> with <code>python3.11-full<\/code> for IDE, pip package manager, etc.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/apt-python311.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-43246\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/apt-python311-600x274.webp\" alt=\"\" width=\"600\" height=\"274\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/apt-python311-600x274.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/apt-python311-300x137.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/apt-python311-768x351.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/apt-python311.webp 779w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<h4>Verify:<\/h4>\n<p>To verify, run <code>python3.11 --version<\/code>, <code>python3.11 -m pip --version<\/code> in terminal.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/verify-py311.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-43247\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/verify-py311-600x214.webp\" alt=\"\" width=\"600\" height=\"214\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/verify-py311-600x214.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/verify-py311-300x107.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/verify-py311-768x274.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/verify-py311.webp 775w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<h4>Set Python 3.11 as default<\/h4>\n<p><b>NOTE: change default <code>Python3<\/code> in Ubuntu may cause issues for some default apps, such as GNOME Terminal<\/b><\/p>\n<p>You may set the new Python package as default by using <code>update-alternatives<\/code> command line tool.<\/p>\n<p>1. First, run command to create symbolic links for system default python (change <code>python3.10<\/code> depends your Ubuntu edition)<\/p>\n<pre>sudo update-alternatives --install \/usr\/bin\/python3 python3 \/usr\/bin\/python3.10 110<\/pre>\n<p>2. Then, add the new Python 3.11 via command:<\/p>\n<pre>sudo update-alternatives --install \/usr\/bin\/python3 python3 \/usr\/bin\/python3.11 100<\/pre>\n<p>3. After that, you may choose which Python as Python3 at any time by running command:<\/p>\n<pre>sudo update-alternatives --config python3<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/python311-default.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-43248\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/python311-default-600x215.webp\" alt=\"\" width=\"600\" height=\"215\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/python311-default-600x215.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/python311-default-300x108.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/python311-default-768x275.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/python311-default.webp 1007w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<h4>Compile and install Python 3.11 manually from source<\/h4>\n<p>User may also compile the programming language from source tarball manually.<\/p>\n<p>First, download the source from <a href=\"https:\/\/www.python.org\/downloads\/\" target=\"_blank\" rel=\"noopener\">Python web site<\/a>, then you may follow this <a href=\"https:\/\/ubuntuhandbook.org\/index.php\/2021\/10\/compile-install-python-3-10-ubuntu\/\" target=\"_blank\" rel=\"noopener\">step by step guide<\/a> that I&#8217;ve tested in my <strong>Ubuntu 22.10<\/strong> machine.<\/p>","protected":false},"excerpt":{"rendered":"<p>The popular Python programming language released version 3.11 today. Here&#8217;s the new features and how to install guide for all current Ubuntu releases. Python 3.11 claimed to be 10-60% faster than the previous 3.10, and features: Exception Groups and except* to raise and handle multiple unrelated exceptions simultaneously. Add add_note() method to BaseException to enrich [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":34796,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[2045],"class_list":["post-43244","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-python"],"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/43244","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=43244"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/43244\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/34796"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=43244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=43244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=43244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}