{"id":161399,"date":"2026-03-21T19:13:18","date_gmt":"2026-03-21T16:13:18","guid":{"rendered":"https:\/\/cloudspinx.com\/?p=66378"},"modified":"2026-03-21T19:13:19","modified_gmt":"2026-03-21T16:13:19","slug":"install-python-debian","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/install-python-debian\/","title":{"rendered":"How To Install Python 3.13 on Debian 13 (Trixie)"},"content":{"rendered":"\n<p>Python is a general-purpose programming language used across web development, data science, machine learning, automation, and system administration. It has clean syntax, a large standard library, and runs on every major platform. Python 3.13 is the default interpreter in Debian 13 (Trixie), so installing it takes a single apt command. For those who need the absolute latest patch release (3.13.12 at the time of writing), building from source is straightforward.<\/p>\n\n\n\n<p>This guide covers two methods to install Python 3.13 on Debian 13 (Trixie) &#8211; from the default APT repositories and from source. We also cover setting up virtual environments with <code>venv<\/code>, using <code>pip<\/code> to manage packages, and verifying the installation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A server or workstation running Debian 13 (Trixie)<\/li>\n\n\n\n<li>Root or sudo access<\/li>\n\n\n\n<li>Internet connectivity to download packages or source tarballs<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Method 1: Install Python 3.13 on Debian 13 from APT<\/h2>\n\n\n\n<p>Debian 13 Trixie ships Python 3.13 as its default Python 3 interpreter. This is the recommended method for most users.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Update system packages<\/h3>\n\n\n\n<p>Start by updating the package index and upgrading existing packages.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update && sudo apt upgrade -y<\/code><\/pre>\n\n\n\n<p>Reboot if a kernel update was applied.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>[ -f \/var\/run\/reboot-required ] && sudo reboot -f<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Install Python 3.13<\/h3>\n\n\n\n<p>Install the Python 3 interpreter along with the <code>venv<\/code> module and development headers.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install python3 python3-venv python3-dev python3-pip -y<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Verify the installation<\/h3>\n\n\n\n<p>Confirm Python 3.13 is installed and working.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">python3 --version<\/mark>\nPython 3.13.5<\/code><\/pre>\n\n\n\n<p>Check that <code>pip<\/code> is available.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">pip3 --version<\/mark>\npip 24.3.1 from \/usr\/lib\/python3\/dist-packages\/pip (python 3.13)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Method 2: Install Python 3.13 from Source on Debian 13<\/h2>\n\n\n\n<p>Building from source gives you the latest patch release with all security fixes and performance improvements. This is useful when you need a newer version than what Debian ships or want to enable experimental features like the free-threaded build or JIT compiler. If you&#8217;re working with <a href=\"https:\/\/computingforgeeks.com\/how-to-install-python-on-ubuntu\/\" target=\"_blank\" rel=\"noreferrer noopener\">Python on Ubuntu<\/a> as well, the source build process is similar.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Install build dependencies<\/h3>\n\n\n\n<p>Install the compiler toolchain and all libraries needed for a full-featured Python build.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>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 liblzma-dev -y<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Download Python source<\/h3>\n\n\n\n<p>Download the latest Python 3.13 source tarball from the <a href=\"https:\/\/www.python.org\/downloads\/source\/\" target=\"_blank\" rel=\"noreferrer noopener\">official Python downloads page<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/www.python.org\/ftp\/python\/3.13.12\/Python-3.13.12.tar.xz<\/code><\/pre>\n\n\n\n<p>Extract the archive.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tar -xvf Python-3.13.12.tar.xz<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Configure and compile<\/h3>\n\n\n\n<p>Change into the source directory and run the configure script with optimizations enabled. The <code>--enable-optimizations<\/code> flag runs profile-guided optimization (PGO), which makes the final binary noticeably faster.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd Python-3.13.12\n.\/configure --enable-optimizations<\/code><\/pre>\n\n\n\n<p>Compile and install using <code>altinstall<\/code> to avoid overwriting the system Python.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo make altinstall<\/code><\/pre>\n\n\n\n<p>The <code>altinstall<\/code> target installs the binary as <code>python3.13<\/code> instead of <code>python3<\/code>, keeping the system default intact. This compilation can take 5-15 minutes depending on hardware.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Verify the source build<\/h3>\n\n\n\n<p>Check that the newly built Python is available.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">python3.13 --version<\/mark>\nPython 3.13.12<\/code><\/pre>\n\n\n\n<p>The binary is installed to <code>\/usr\/local\/bin\/python3.13<\/code>. If you want to make it the default <code>python3<\/code>, use update-alternatives.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo update-alternatives --install \/usr\/bin\/python3 python3 \/usr\/local\/bin\/python3.13 1<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Setting Up Python Virtual Environments on Debian<\/h2>\n\n\n\n<p>Virtual environments isolate project dependencies so they do not conflict with system packages or other projects. Always use a virtual environment for Python development &#8211; never install packages globally with pip on a modern Debian system, as it will be blocked by default (PEP 668).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Create a virtual environment<\/h3>\n\n\n\n<p>Create a new virtual environment in your project directory.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python3 -m venv ~\/myproject\/venv<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Activate the virtual environment<\/h3>\n\n\n\n<p>Activate it before installing any packages.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>source ~\/myproject\/venv\/bin\/activate<\/code><\/pre>\n\n\n\n<p>Your shell prompt changes to show the active environment name.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">which python3<\/mark>\n\/home\/user\/myproject\/venv\/bin\/python3<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Install packages inside the venv<\/h3>\n\n\n\n<p>With the environment active, use pip to install packages. They are contained entirely within the venv directory. For example, to install a web framework like <a href=\"https:\/\/computingforgeeks.com\/install-flask-with-gunicorn-nginx-rocky\/\" target=\"_blank\" rel=\"noreferrer noopener\">Flask with Gunicorn<\/a> for a web project:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install flask<\/code><\/pre>\n\n\n\n<p>Verify the installed package.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">pip show flask<\/mark>\nName: Flask\nVersion: 3.1.0\nSummary: A simple framework for building complex web applications.\nLocation: \/home\/user\/myproject\/venv\/lib\/python3.13\/site-packages\nRequires: blinker, click, itsdangerous, Jinja2, Werkzeug<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Deactivate the virtual environment<\/h3>\n\n\n\n<p>When finished working in the project, deactivate the environment.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>deactivate<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Using pip to Manage Python Packages<\/h2>\n\n\n\n<p>The <code>pip<\/code> package manager comes bundled with Python 3.13 on Debian 13. Here are the most common operations &#8211; always run these inside a virtual environment.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install a package<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install <em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">package_name<\/mark><\/em><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install a specific version<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install <em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">package_name<\/mark><\/em>==2.0.1<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Upgrade a package<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install --upgrade <em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">package_name<\/mark><\/em><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">List installed packages<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>pip list<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Uninstall a package<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>pip uninstall <em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">package_name<\/mark><\/em><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Export and reproduce dependencies<\/h3>\n\n\n\n<p>Save all current dependencies to a requirements file for reproducible deployments.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip freeze > requirements.txt<\/code><\/pre>\n\n\n\n<p>Reinstall from a requirements file on another machine or environment.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install -r requirements.txt<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Running a Python Script on Debian 13<\/h2>\n\n\n\n<p>Test your installation by running the interactive interpreter.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">python3<\/mark>\nPython 3.13.5 (main, Mar 10 2026, 12:15:42) [GCC 14.2.0] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>><\/code><\/pre>\n\n\n\n<p>Python 3.13 includes an improved interactive interpreter with syntax highlighting, multiline editing, and colored output. Try a quick test.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>>>> <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">import sys<\/mark>\n>>> <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">print(f\"Python {sys.version}\")<\/mark>\nPython 3.13.5 (main, Mar 10 2026, 12:15:42) [GCC 14.2.0]\n>>> <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">exit()<\/mark><\/code><\/pre>\n\n\n\n<p>To run a script from a file, create a simple test script. If you plan to build larger applications, consider using <a href=\"https:\/\/computingforgeeks.com\/how-to-install-django-on-debian-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\">Django on Debian<\/a> for web projects.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vi ~\/hello.py<\/code><\/pre>\n\n\n\n<p>Add the following content:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/env python3\nimport platform\n\nprint(f\"Hello from Python {platform.python_version()}\")\nprint(f\"Running on {platform.system()} {platform.release()}\")<\/code><\/pre>\n\n\n\n<p>Run the script.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">python3 ~\/hello.py<\/mark>\nHello from Python 3.13.5\nRunning on Linux 6.12.27-amd64<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Python 3.13 is available out of the box on Debian 13 Trixie through APT, making installation a one-command operation. For the latest patch release, building from source with <code>--enable-optimizations<\/code> gives you a PGO-optimized binary. The same source build approach works on <a href=\"https:\/\/computingforgeeks.com\/install-python-rhel-rocky-almalinux\/\" target=\"_blank\" rel=\"noreferrer noopener\">RHEL, Rocky Linux, and AlmaLinux<\/a> if you manage mixed environments.<\/p>\n\n\n\n<p>For production deployments, always use virtual environments to isolate dependencies, pin package versions with <code>requirements.txt<\/code>, and keep Python updated with security patches from Debian&#8217;s package manager.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python is a general-purpose programming language used across web development, data science, machine learning, automation, and system administration. It has clean syntax, a large standard library, and runs on every major platform. Python 3.13 is the default interpreter in Debian 13 (Trixie), so installing it takes a single apt command. For those who need the &#8230; <a title=\"How To Install Python 3.13 on Debian 13 (Trixie)\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/install-python-debian\/\" aria-label=\"Read more about How To Install Python 3.13 on Debian 13 (Trixie)\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":66835,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,690,299,50,68],"tags":[35981,39652],"class_list":["post-161399","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-debian","category-dev","category-how-to","category-linux-tutorials","category-programming","tag-debian-11","tag-python-3-13"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/161399","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=161399"}],"version-history":[{"count":1,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/161399\/revisions"}],"predecessor-version":[{"id":163158,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/161399\/revisions\/163158"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/66835"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=161399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=161399"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=161399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}