{"id":9161,"date":"2024-02-20T13:17:32","date_gmt":"2024-02-20T13:17:32","guid":{"rendered":"https:\/\/cheapwindowsvps.com\/blog\/how-to-upgrade-python-on-windows-a-comprehensive-guide\/"},"modified":"2025-01-20T10:22:58","modified_gmt":"2025-01-20T10:22:58","slug":"how-to-upgrade-python-on-windows-a-comprehensive-guide","status":"publish","type":"post","link":"https:\/\/cheapwindowsvps.com\/blog\/how-to-upgrade-python-on-windows-a-comprehensive-guide\/","title":{"rendered":"How to Upgrade Python on Windows: A Comprehensive Guide"},"content":{"rendered":"<p><div>This article will explain the four ways to upgrade to a new version of Python on a Windows system: installer, Microsoft Store, Winget, and Chocolatey. You will also learn how to use different versions of Python on your system and how to uninstall an old version.<\/div>\n<\/p>\n<p><p>To follow along, you should be on a Windows computer and have Python installed. The examples in the article were tested on Windows 11.<a rel=\"nofollow noopener\" target=\"_blank\"><\/a><\/p>\n<\/p>\n<p><h2>Check the current Python version<\/h2>\n<\/p>\n<p><p>Before we upgrade to the latest stable version of Python, version 3.12, you should check the version running on your machine. An upgrade may not be necessary.<\/p>\n<\/p>\n<p><p>Open a command prompt and run <em>python<\/em> as below to see the <em>version<\/em> you have installed<\/p>\n<pre>python --version<\/p><p><\/pre>\n<p>Checking Python&#8217;s version<\/p>\n<h2>Upgrade Python with the installer<\/h2>\n<\/p>\n<p><p>In this section, you will learn how to upgrade Python using the official installer. <a href=\"https:\/\/www.python.org\/downloads\/\" rel=\"nofollow noopener\" target=\"_blank\">Open the Python official website<\/a> and download the latest stable version.<\/p>\n<\/p>\n<p><p>Run the installer by double-clicking the downloaded file in Explorer to start the installation process.<\/p>\n<\/p>\n<p><p>The Python installer setup file<\/p>\n<\/p>\n<p><p>A setup window should open up as below.<\/p>\n<p> <a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Configuring-the-installer.png\" rel=\"nofollow noopener\" target=\"_blank\">Configuring the installer<\/a> <\/p>\n<p>At the setup window, you can fine-tune the installation parameters. The key things to note are:<\/p>\n<ul>\n<li>Enable the option to <strong>install <em>py.exe<\/em><\/strong> with <strong>admin privileges<\/strong>. <em>Py.exe<\/em> is a Python launcher for Windows only, allowing you to easily execute Python scripts from the command line.<\/li>\n<li>Check the option to add this version of Python to the PATH variable so you just type P<em>ython<\/em> on the command line. Without this option, you may call Python by specifying its location.<\/li>\n<li>The installation location and additional features\n<ul>\n<li><strong>Install Now<\/strong> &#8211; This will install Python to the default location with the default suite of supporting software and configuration options.<\/li>\n<li><strong>Customize installation<\/strong> &#8211; Cherry-pick supporting software and set a custom installation location.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><p>The setup window should now look like the shot below. You will notice a User Account Control (UAC) shield by <strong>Install Now,<\/strong> indicating that the installation will request admin privileges as it progresses.<\/p>\n<\/p>\n<p><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Select-options-in-the-Python-installer.png\" rel=\"nofollow noopener\" target=\"_blank\">Select options in the Python installer<\/a> <\/p>\n<p><p>Select options in the Python installer<\/p>\n<\/p>\n<p><p>Select <strong>Install Now<\/strong> to start.<\/p>\n<\/p>\n<p><p>At the UAC prompt, select <strong>Yes<\/strong> to elevate privileges and continue.<\/p>\n<\/p>\n<div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Elevating-privileges-for-installation.png\" rel=\"nofollow noopener\" target=\"_blank\"><\/a><\/p>\n<p>Elevating privileges for installation<\/p>\n<\/div>\n<p>The installation will end, as shown in the shot below.<\/p>\n<\/p>\n<p><p>Select <strong>Disable path length limit<\/strong> to ensure Python programs <a href=\"https:\/\/docs.python.org\/3\/using\/windows.html\" rel=\"nofollow noopener\" target=\"_blank\">that deal with long paths can run error-free<\/a>. This is Windows-specific. By default, Windows only allows you to use paths that are 260 characters or less.<\/p>\n<\/p>\n<p><p>Congratulations, you have just upgraded to Python 3.12. Confirm its presence by running <em>py &#8211;version<\/em> in PowerShell. The launcher defaults to the highest Python version available.<\/p>\n<\/p>\n<p><pre>py --version<\/pre>\n<\/p>\n<p><div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Checking-the-Python-version.png\" rel=\"nofollow noopener\" target=\"_blank\">Checking the Python version<\/a><\/div>\n<\/p>\n<p><p>The older version, version 3.10, is still around. You can see that by running <em>py<\/em> with the <em>list<\/em> switch.<\/p>\n<\/p>\n<p><pre>py --list<\/pre>\n<\/p>\n<p><div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Listing-installed-Python-versions.png\" rel=\"nofollow noopener\" target=\"_blank\">Listing installed Python versions<\/a><\/div>\n<\/p>\n<p><p>You can maintain various versions of Python on your system without causing any conflict. This approach lets you transition scripts slowly, after verifying them with the updated version.<\/p>\n<\/p>\n<p><h3>Run the new Python version<\/h3>\n<\/p>\n<p><p>As discussed earlier, initiating the new Python interpreter is as easy as running the <em>py<\/em> command. By default, the launcher chooses the topmost Python version it can locate on your system.<\/p>\n<\/p>\n<p><pre>py<\/p><p><\/pre>\n<\/p>\n<p><div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Running-the-new-Python-with-Py.png\" rel=\"nofollow noopener\" target=\"_blank\"><\/a><\/p>\n<p>Running the new Python with Py<\/p>\n<\/div>\n<p><p>You can also specify a version with the launcher. For example, you can execute <em>py<\/em> as follows to launch version 3.10,<\/p>\n<\/p>\n<p><pre>py -3.10<\/p><p><\/pre>\n<p>&nbsp;<\/p>\n<\/p>\n<p><div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Running-the-old-version-with-python.png\" rel=\"nofollow noopener\" target=\"_blank\">Running the old version with python<\/a><\/p>\n<p><p>Running the old version with python<\/p>\n<\/div>\n<p><h3>Running the new Python alongside Python 2<\/h3>\n<\/p>\n<p><p>You can also start Python by executing the <em>python<\/em> command. However, when you start Python this way, you do not necessarily launch the latest Python. You launch the first available Python executable.<\/p>\n<\/p>\n<p><p>The system searches the folders listed in the Path variable and runs the first Python executable it can find. Path is a variable that contains a list of folders that should be searched when the shell is looking for an executable.<\/p>\n<\/p>\n<p><p>Two primary considerations influence the version that the <em>python<\/em> command initiates;<\/p>\n<\/p>\n<ul>\n<li>The sequence in which all the versions were installed<\/li>\n<li>The adjustments that were implemented at the time of Python installation.<\/li>\n<\/ul>\n<p><p>Automatically, these two variables change the Path variable and determine which version is discovered first.<\/p>\n<\/p>\n<p><p>For instance, on a system with Python 2.7, running <em>python<\/em> usually starts <strong>Python 2.7 <\/strong>instead of the freshly installed update.<\/p>\n<\/p>\n<p><p>python<\/p>\n<\/p>\n<p><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Running-the-old-version-with-python.png\" rel=\"nofollow noopener\" target=\"_blank\">Running the old version with python<\/a><\/p>\n<p><p>You can confirm which python interpreter will be found first by using the <em>where.exe<\/em> command<\/p>\n<\/p>\n<p><p>where.exe python<\/p>\n<\/p>\n<p><div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Listing-python-executables-with-where.exe_.png\" rel=\"nofollow noopener\" target=\"_blank\">Listing python executables with where.exe<\/a><\/div>\n<\/p>\n<p><p>For my machine, Python 2 is the first on the list. Yours may be different.<\/p>\n<\/p>\n<p><p>Because of this behavior, I prefer the launcher(py) to Python when launching Python. Py gives you more control and flexibility over which version will run.<\/p>\n<\/p>\n<p><p>When you cannot use the Py launcher, <a href=\"https:\/\/www.howtogeek.com\/118594\/how-to-edit-your-system-path-for-easy-command-line-access\/\" rel=\"nofollow noopener\" target=\"_blank\">edit Path<\/a> to ensure your preferred version of Python is found first. An example of such a situation is with third-party applications that are hard-coded to use <em>python<\/em> instead of <em>py<\/em>.<\/p>\n<\/p>\n<p><p>As a last resort, you can specify the full location of the Python executable to start a particular version. For example, instead of just typing <em>python<\/em>, type;<\/p>\n<\/p>\n<p><pre>c:python27python.exe<\/pre>\n<\/p>\n<p><p>Running Python with the full location<\/p>\n<\/p>\n<p><p>You can find out the full path for your Python installation with the <em>where<\/em> command as below;<\/p>\n<\/p>\n<p><pre>where.exe python<\/pre>\n<\/p>\n<p><p><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Finding-the-location-of-your-Python-interpreter.png\" rel=\"nofollow noopener\" target=\"_blank\">Finding the location of your Python interpreter<\/a><\/p>\n<\/p>\n<p><h2>Upgrade Python with Winget<\/h2>\n<\/p>\n<p><p>Winget is a built-in command-line tool that streamlines and automates the installation of frequently used Windows programs. It functions as Microsoft\u2019s package manager and is already pre-installed in several Windows versions. It is akin to an apt package manager in <a href=\"https:\/\/ubuntu.com\/server\/docs\/package-management\" rel=\"nofollow noopener\" target=\"_blank\">Ubuntu<\/a>.<\/p>\n<\/p>\n<p><p>Launch <em>PowerShell<\/em> and execute the <em>winget<\/em> command as specified below, to update Python:<\/p>\n<\/p>\n<p><pre>winget install python.python.3.12<\/p><p><\/pre>\n<\/p>\n<p><p>A progress bar should appear, indicating the search and download progress of the setup files.<\/p>\n<\/p>\n<p><div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Upgrading-Python-with-Winget.png\" rel=\"nofollow noopener\" target=\"_blank\">Upgrading Python with Winget<\/a><\/div>\n<\/p>\n<p><p>After the download, a graphical <strong>Setup<\/strong> progress window should automatically pop up as Python is being installed.<\/p>\n<\/p>\n<p><div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Viewing-installation-progress.png\" rel=\"nofollow noopener\" target=\"_blank\">Viewing installation progress<\/a><\/div>\n<\/p>\n<p><p>You will be automatically redirected to PowerShell with a success notice upon completion.<\/p>\n<\/p>\n<p><div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Completing-the-installation-successfully.png\" rel=\"nofollow noopener\" target=\"_blank\">Completing the installation successfully<\/a><\/p>\n<p>Completing the installation successfully<\/p>\n<\/div>\n<p><p>You can also install the <em>python<\/em> launcher via <em>winget<\/em> as follows<\/p>\n<\/p>\n<p><pre>winget install python.launcher<\/pre>\n<\/p>\n<p><div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Installing-the-launcher-via-Winget.png\" rel=\"nofollow noopener\" target=\"_blank\">Installing the launcher via Winget<\/a><\/p>\n<p>Installing the launcher via Winget<\/p>\n<\/div>\n<p><h2>Upgrade Python with Microsoft Store<\/h2>\n<\/p>\n<p><p>Another way to upgrade Python is by installing it from the Microsoft Store app on your desktop. The store hosts multiple versions of Python\u2019s interpreter.<\/p>\n<\/p>\n<p><p>Select the Microsoft Store app from the taskbar to open up the store.<\/p>\n<\/p>\n<p><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Launching-the-Microsoft-Store.png\" rel=\"nofollow noopener\" target=\"_blank\">Launching the Microsoft Store<\/a><\/p>\n<p><p>Search for <em>python<\/em> to bring up a list of all versions available in the store. Select <strong>Get<\/strong> on the version you require (3.12) to kick off the installation.<\/p>\n<\/p>\n<p><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Searching-for-Python.png\" rel=\"nofollow noopener\" target=\"_blank\">Searching for Python<\/a><\/p>\n<p><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Installing-Python-from-the-Microsoft-Store.png\" rel=\"nofollow noopener\" target=\"_blank\">Installing Python from the Microsoft Store<\/a><\/p>\n<p><p>After the installation, you can use Python 3.12 by typing in <em>python3.12<\/em> in a terminal.<\/p>\n<\/p>\n<p>&#8220;`html<\/p>\n<p><p><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Starting-Python-with-appended-version-number.png\" rel=\"nofollow noopener\" target=\"_blank\">Starting Python with appended version number<\/a><\/p>\n<\/p>\n<p><p>Python from the store does not come with a Py launcher. Instead, it enables you to launch Python with the version number as above. This is unique to installations from the Microsoft Store.<\/p>\n<\/p>\n<p><p>You can launch Python with the <em>python<\/em> command as well. This depends on the value of your Path variable.<\/p>\n<\/p>\n<p>&#8220;`<\/p>\n<p><p><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Starting-Python-with-the-python-command.png\" rel=\"nofollow noopener\" target=\"_blank\">Starting Python with the python command<\/a><\/p>\n<\/p>\n<p><p>Note: If typing python at the command line opens up Microsoft Store instead,<\/p>\n<\/p>\n<ol>\n<li>Open <strong>App execution Aliases<\/strong> from the <strong>Start Menu<\/strong><\/li>\n<li>Ensure the aliases for <strong>Python 3.12<\/strong> point to <strong>python3.exe<\/strong> and <strong>python.exe<\/strong> respectively.<\/li>\n<li>Ensure the aliases for <strong>Python 3.12<\/strong> are turned <strong>On.<\/strong><\/li>\n<\/ol>\n<p><div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Enabling-app-execution-aliases.png\" rel=\"nofollow noopener\" target=\"_blank\">Enabling app execution aliases<\/a><\/p>\n<p>Enabling app execution aliases<\/p>\n<\/div>\n<p><h2>Upgrade Python with Chocolatey<\/h2>\n<\/p>\n<p><p>Chocolatey is a third-party package manager that makes installing many applications from the command line easy. If you already have Chocolatey installed, installing Python is as simple as executing the one-liner below in an elevated terminal window.<\/p>\n<\/p>\n<p><pre>choco install python -y<\/p><p><\/pre>\n<\/p>\n<p><div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Installing-Python-with-Chocolatey.png\" rel=\"nofollow noopener\" target=\"_blank\">Installing Python with Chocolatey<\/a><\/div>\n<\/p>\n<p><p>The <em>-y<\/em> switch completes the execution without further user interaction. Chocolatey\u2019s Python installation installs the launcher alongside. It also edits the Path variable to help the system first find the newly installed Python.<\/p>\n<\/p>\n<p><p>To use Python immediately, just restart PowerShell.<\/p>\n<\/p>\n<p><p>Next, type <em>python<\/em> or <em>py<\/em> to start up the most recently installed version.<\/p>\n<\/p>\n<p>&#8220;`<\/p>\n<p><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Starting-Python.png\" rel=\"nofollow noopener\" target=\"_blank\">Starting Python<\/a> <\/p>\n<p><p>You can also upgrade to a specific version as follows<\/p>\n<\/p>\n<p><pre>choco install python311<\/pre>\n<\/p>\n<p>&#8220;`<\/p>\n<p><h2>Uninstall the old version of Python<\/h2>\n<\/p>\n<p><p>The most straightforward way to install Python is to go to Settings -&gt; Apps -&gt; Apps and Features. Regardless of the installation method, you will likely find most Python installations listed here.<\/p>\n<\/p>\n<p><p><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Listing-installed-Python-versions-in-Apps-and-features.png\" rel=\"nofollow noopener\" target=\"_blank\">Listing installed Python versions in Apps and features<\/a><\/p>\n<\/p>\n<p><p>Select the version you want to remove and click <strong>Uninstall<\/strong>.<\/p>\n<\/p>\n<p><div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2024\/02\/Uninstalling-Python-via-Apps-and-features.png\" rel=\"nofollow noopener\" target=\"_blank\">Uninstalling Python via Apps and features<\/a><\/div>\n<p>You can also uninstall Python with the package managers you used to install them as below;<\/p>\n<div>\n<h2>Subscribe to 4sysops newsletter!<\/h2>\n<\/div>\n<pre>choco uninstall python312<\/p><p>winget uninstall python.python.3.12<\/p><p><\/pre>\n<\/p>\n<p><h2>Conclusion<\/h2><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article will explain the four ways to upgrade to a new version of Python on a Windows system: installer, Microsoft Store, Winget, and Chocolatey. You will also learn how to use different versions of Python on your system and how to uninstall an old version. To follow along, you should be on a Windows [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9162,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[92,95,165],"tags":[],"class_list":["post-9161","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","category-devops","category-python"],"_links":{"self":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts\/9161","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/comments?post=9161"}],"version-history":[{"count":2,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts\/9161\/revisions"}],"predecessor-version":[{"id":10379,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts\/9161\/revisions\/10379"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/media\/9162"}],"wp:attachment":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/media?parent=9161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/categories?post=9161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/tags?post=9161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}