{"id":45432,"date":"2024-02-03T12:46:18","date_gmt":"2024-02-03T12:46:18","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=45432"},"modified":"2024-10-09T15:58:09","modified_gmt":"2024-10-09T15:58:09","slug":"install-python-3-13-ubuntu","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2024\/02\/install-python-3-13-ubuntu\/","title":{"rendered":"How to Install Python 3.13 Stable in Ubuntu 24.04 \/ 22.04"},"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>This simple tutorial shows how to install Python 3.13 in <b>Ubuntu 24.04<\/b>, <b>Ubuntu 22.04<\/b>, and\/or <b>Ubuntu 20.04 LTS<\/b>.<\/p>\n<p>Python 3.13.0 was released on Oct 7, 2024 as the new major release that features <b>new interactive interpreter<\/b>, that supports multi-line editing, REPL-specific commands such as <code>help<\/code>, <code>exit<\/code>, <code>clear<\/code>, and <code>quit<\/code>, interactive help, history browsing, and &#8216;paste mode&#8217; for pasting larger blocks of code.<\/p>\n<p>CPython now has <b>experimental support for free-threaded mode<\/b> for running threads in parallel on available CPU cores, though disabled by default.<\/p>\n<p>Other changes in Python 3.13.0 include:<\/p>\n<ul>\n<li>New interactive interpreter, features multi-line editing and color support, as well as colorized exception tracebacks.<\/li>\n<li>Experimental free-threaded build mode.<\/li>\n<li>A preliminary, experimental JIT.<\/li>\n<li>The (cyclic) garbage collector is now incremental.<\/li>\n<li>Include a modified version of mimalloc, and enabled by default if supported by the platform.<\/li>\n<li>Docstrings now have their leading indentation stripped, reducing memory use and the size of .pyc files.<\/li>\n<li>The dbm module has a new dbm.sqlite3 backend that is used by default when creating new files.<\/li>\n<li>Support for type defaults in type parameters.<\/li>\n<li>New type narrowing annotation, typing.TypeIs.<\/li>\n<li>New annotation for read-only items in TypeDicts.<\/li>\n<li>Removals of many deprecated modules: aifc, audioop, chunk, cgi, cgitb, crypt, imghdr, mailcap, msilib, nis, nntplib, ossaudiodev, pipes, sndhdr, spwd, sunau, telnetlib, uu, xdrlib, lib2to3.<\/li>\n<\/ul>\n<p>For more, see the official <a href=\"https:\/\/docs.python.org\/release\/3.13.0\/whatsnew\/changelog.html\" target=\"_blank\" rel=\"noopener\">release note<\/a>.<\/p>\n<p><!--more--><\/p>\n<div id=\"attachment_47341\" style=\"width: 620px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/10\/python3-newinteractive-shell.webp\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-47341\" class=\"size-large wp-image-47341\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/10\/python3-newinteractive-shell-700x390.webp\" alt=\"\" width=\"610\" height=\"340\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/10\/python3-newinteractive-shell-700x390.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/10\/python3-newinteractive-shell-300x167.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/10\/python3-newinteractive-shell.webp 706w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><p id=\"caption-attachment-47341\" class=\"wp-caption-text\">Python 3.13 shell, with colors, multi-line editing, etc support<\/p><\/div>\n<h3>Option 1: Install Python 3.13 from Ubuntu PPA<\/h3>\n<p>The popular <a href=\"https:\/\/launchpad.net\/~deadsnakes\/+archive\/ubuntu\/ppa\" target=\"_blank\" rel=\"noopener\">deadsnakes PPA<\/a> has built the latest Python 3.13 for Ubuntu 20.04, Ubuntu 22.04, and Ubuntu 24.04.<\/p>\n<p>1. First, press <code>Ctrl+Alt+T<\/code> 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 visual feedback) for sudo authentication and hit Enter to continue.<\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/03\/deadbeef-ppa-jammy.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-43758\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/03\/deadbeef-ppa-jammy-600x442.webp\" alt=\"\" width=\"600\" height=\"442\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/03\/deadbeef-ppa-jammy-600x442.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/03\/deadbeef-ppa-jammy-300x221.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/03\/deadbeef-ppa-jammy.webp 723w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>2. Then, install Python 3.13 by running command (Linux Mint needs to run <code>sudo apt update<\/code> first to refresh package cache):<\/p>\n<pre>sudo apt install python3.13-full<\/pre>\n<p>For choice, replace <code>python3.13<\/code> in command with <code>python3.13-full<\/code> to also install GNU dbm database support, tkinter, as well as the IDE.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/apt-python313.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45433\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/apt-python313-700x324.webp\" alt=\"\" width=\"610\" height=\"282\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/apt-python313-700x324.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/apt-python313-300x139.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/apt-python313-768x356.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/apt-python313.webp 822w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>3. After installation, verify its version by running command:<\/p>\n<pre>python3.13 --version<\/pre>\n<p>4. <b>To get pip package installer for Python3.13<\/b>, just run the <code>ensurepip<\/code> module which provides support for bootstrapping the pip installer into an existing Python installation.<\/p>\n<pre>python3.13 -m ensurepip --upgrade<\/pre>\n<p>Then verify via: <code>python3.13 -m pip --version<\/code>, and upgrade it via <code>python3.13 -m pip install --upgrade pip<\/code>.<\/p>\n<h3>Option 2: Compile Python 3.13 from source tarball<\/h3>\n<p>1. First, press Ctrl+Alt+T on keyboard to open terminal. When it opens, run command to install the required libraries for building Python:<\/p>\n<pre>sudo apt install wget build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev<\/pre>\n<p>2. Then, select download the most recent dev version of Python 3.13 (so far <code>Python-3.13.0.tar.xz<\/code>) from the link page below:<\/p>\n<div class=\"wp-block-buttons aligncenter\">\n<div class=\"wp-block-button is-style-fill\"><a class=\"wp-block-button__link has-vivid-cyan-blue-to-vivid-purple-gradient-background has-text-color has-background\" href=\"https:\/\/www.python.org\/ftp\/python\/3.13.0\/\" target=\"_blank\" rel=\"noreferrer noopener\">Download Python 3.13<\/a><\/div>\n<\/div>\n<p>3. Next, extract the source tarball in file manager. Then, right-click on extracted folder and select &#8220;Open in terminal&#8221; to open that folder as working directory in terminal.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/open-python3103-terminal.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-47343\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/open-python3103-terminal-700x380.webp\" alt=\"\" width=\"610\" height=\"331\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/open-python3103-terminal-700x380.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/open-python3103-terminal-300x163.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/open-python3103-terminal-768x417.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/02\/open-python3103-terminal.webp 1214w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>4. In the pop-up terminal, configure the source via command:<\/p>\n<pre>.\/configure --enable-optimizations<\/pre>\n<p>For choice, you can run <code>.\/configure --help<\/code> to print more configure options.<\/p>\n<p>Then, compile by starting 4 threads in parallel:<\/p>\n<pre>make -j4<\/pre>\n<p>And finally install Python 3.13:<\/p>\n<pre>sudo make install<\/pre>\n<p>Finally, verify via command: <code>python3.13 --version<\/code> and <code>pip3.13 --version<\/code>.<\/p>\n<h3>Uninstall:<\/h3>\n<p>For Python 3.13 installed from PPA, open terminal and run command to remove it:<\/p>\n<pre>sudo apt remove --autoremove python3.13<\/pre>\n<p>Also remove the PPA by running command:<\/p>\n<pre>sudo add-apt-repository --remove ppa:deadsnakes\/ppa<\/pre>\n<p>If you compiled it from source, then try running the command below from source folder until you removed it:<\/p>\n<pre>sudo make uninstall<\/pre>\n<p>Or, manually delete all the corresponding files and folders (run <code>whereis python3.13<\/code> to tell).<\/p>","protected":false},"excerpt":{"rendered":"<p>This simple tutorial shows how to install Python 3.13 in Ubuntu 24.04, Ubuntu 22.04, and\/or Ubuntu 20.04 LTS. Python 3.13.0 was released on Oct 7, 2024 as the new major release that features new interactive interpreter, that supports multi-line editing, REPL-specific commands such as help, exit, clear, and quit, interactive help, history browsing, and &#8216;paste [&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":[2086,2045],"class_list":["post-45432","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-programming","tag-python"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/45432","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=45432"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/45432\/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=45432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=45432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=45432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}