{"id":58509,"date":"2024-01-30T06:17:15","date_gmt":"2024-01-30T06:17:15","guid":{"rendered":"https:\/\/www.askpython.com\/?p=58509"},"modified":"2025-04-10T20:42:20","modified_gmt":"2025-04-10T20:42:20","slug":"change-the-python-version-conda","status":"publish","type":"post","link":"https:\/\/www.askpython.com\/python\/examples\/change-the-python-version-conda","title":{"rendered":"How to change the Python version of the conda virtual environment?"},"content":{"rendered":"\n<p>Conda is a powerful open-source package and environment manager for Python that allows users to create, manage, and switch between virtual environments. Changing a Python version of the conda virtual environment is crucial when transitioning between projects that require different Python versions or when updating an existing project to a new Python release. <\/p>\n\n\n\n<p>The Conda virtual environment is an isolated environment where packages and dependencies can be installed without affecting the system&#8217;s global Python installation. They prevent conflicts between projects and make it easy to switch between Python versions. Conda allows users to create and manage these environments effortlessly.<\/p>\n\n\n\n<p>With frequent updates and versions, it is necessary to know how to manage different Python versions for your projects. In this article, we will guide you through the process of changing the Python version in an existing conda virtual environment.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>To change the Python version in a Conda virtual environment, activate the environment using <code>conda activate env_name<\/code>, check the current version with <code>python --version<\/code>, list available versions using <code>conda search '^python$'<\/code>, and install a new version with <code>conda install python=x.y<\/code>. This process helps adapt to different project requirements.<\/em><\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Why Change to Different Python Versions<\/h3>\n\n\n\n<p>Before starting the process of changing the Python version of an existing conda environment, let&#8217;s discuss why. Different Python versions have different features and performance improvements. Also, some libraries or packages may only be compatible with certain Python versions. So switching between Python versions in the conda environment is crucial for your projects.<\/p>\n\n\n\n<p><em><strong>Also read: <a href=\"https:\/\/www.askpython.com\/python-modules\/python-anaconda-tutorial\" data-type=\"post\" data-id=\"10679\">Python Anaconda Tutorial \u2013 Getting Started With Anaconda<\/a><\/strong><\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Easy Steps to Update Python in Conda Environments<\/h2>\n\n\n\n<p>Here is a step-by-step guide on how to change the Python version of existing conda virtual environments.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Activate conda virtual environment<\/h3>\n\n\n\n<p>The first step is to activate the conda virtual environment. For the environment in which you want to change the Python version, activate that conda virtual environment. Open a terminal. Here we will use Anaconda Prompt. Use the following command to activate the conda environment:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nconda activate env1\n<\/pre><\/div>\n\n\n<p>This command line activates your conda virtual environment. You can replace the env1 with the actual name of your environment for which you want to change the Python version.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"587\" height=\"77\" src=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_activate.png\" alt=\"Conda Activate\" class=\"wp-image-58515\" srcset=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_activate.png 587w, https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_activate-300x39.png 300w\" sizes=\"auto, (max-width: 587px) 100vw, 587px\" \/><\/figure>\n\n\n\n<p>Here you can see we are in the base environment but after activating the env1 we are now in the env1 environment.<\/p>\n\n\n\n<p>You can directly open a terminal of the environment for which you want to change the Python version by using Anaconda Navigator.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"983\" height=\"360\" src=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_env1T.png\" alt=\"Conda Env1T\" class=\"wp-image-58521\" style=\"width:683px;height:auto\" srcset=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_env1T.png 983w, https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_env1T-300x110.png 300w, https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_env1T-768x281.png 768w\" sizes=\"auto, (max-width: 983px) 100vw, 983px\" \/><\/figure>\n\n\n\n<p>You can see the option Open Terminal, click on it. Now you are in the env1 virtual environment.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Check the current Python version<\/h3>\n\n\n\n<p>You can check the current Python version by using the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\npython --version\n<\/pre><\/div>\n\n\n<p>This command gives the current Python version.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"557\" height=\"65\" src=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_pyv.png\" alt=\"Conda Pyv\" class=\"wp-image-58523\" srcset=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_pyv.png 557w, https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_pyv-300x35.png 300w\" sizes=\"auto, (max-width: 557px) 100vw, 557px\" \/><\/figure>\n\n\n\n<p>The current Python version of the env1 environment is 3.7.16.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. List available Python versions<\/h3>\n\n\n\n<p>Conda provides a list of available Python versions that can be installed in your virtual environment. Use the following command to get the list of available Python versions.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nconda search &quot;^python$&quot;\n<\/pre><\/div>\n\n\n<p>This command provides you with a list of available Python versions.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"882\" height=\"301\" src=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_pyversionlist.png\" alt=\"Conda Pyversionlist\" class=\"wp-image-58524\" style=\"width:677px;height:auto\" srcset=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_pyversionlist.png 882w, https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_pyversionlist-300x102.png 300w, https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_pyversionlist-768x262.png 768w\" sizes=\"auto, (max-width: 882px) 100vw, 882px\" \/><\/figure>\n\n\n\n<p>From the above list identify the version you want to switch to.<\/p>\n\n\n\n<p><em><strong>Also read: <a href=\"https:\/\/www.askpython.com\/python\/conda-vs-pip\" data-type=\"post\" data-id=\"16381\">Conda vs Pip: Choosing your Python package manager<\/a><\/strong><\/em><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. Change Python version<\/h3>\n\n\n\n<p>Now to change the Python version within the active conda virtual environment, use the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nconda install python=3.8\n<\/pre><\/div>\n\n\n<p>Here we use Python version number 3.8. You can replace the Python version with the version number you want to install. Conda will install the specified Python version.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"732\" height=\"60\" src=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_installpy-1.png\" alt=\"Conda Installpy 1\" class=\"wp-image-58525\" srcset=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_installpy-1.png 732w, https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_installpy-1-300x25.png 300w\" sizes=\"auto, (max-width: 732px) 100vw, 732px\" \/><\/figure>\n\n\n\n<p>Enter y to proceed with the installation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Check Python version<\/h3>\n\n\n\n<p>After the installation is complete, you can verify the Python version has been successfully changed by using the following command:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"682\" height=\"73\" src=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_installpy1.png\" alt=\"Conda Installpy1\" class=\"wp-image-58526\" srcset=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_installpy1.png 682w, https:\/\/www.askpython.com\/wp-content\/uploads\/2024\/01\/conda_installpy1-300x32.png 300w\" sizes=\"auto, (max-width: 682px) 100vw, 682px\" \/><\/figure>\n\n\n\n<p>Now you can see the Python version is 3.8.18. Ensure that the displayed Python version matches with the Python version you intended to install.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Now you know how to switch Python versions in your Conda environments! It&#8217;s a simple yet powerful skill that keeps your projects flexible and up-to-date. Whether you&#8217;re adapting to new project requirements or exploring the latest Python features, this knowledge puts you in control. Remember, the right Python version can make all the difference in your coding journey. What exciting project will you tackle next with your newly updated environment?<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">References<\/h2>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/59163078\/how-to-change-python-version-of-existing-conda-virtual-environment\" target=\"_blank\" rel=\"noopener\">https:\/\/stackoverflow.com\/questions\/59163078\/how-to-change-python-version-of-existing-conda-virtual-environment<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Conda is a powerful open-source package and environment manager for Python that allows users to create, manage, and switch between virtual environments. Changing a Python version of the conda virtual environment is crucial when transitioning between projects that require different Python versions or when updating an existing project to a new Python release. The Conda [&hellip;]<\/p>\n","protected":false},"author":79,"featured_media":64039,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-58509","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-examples"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/posts\/58509","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/users\/79"}],"replies":[{"embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/comments?post=58509"}],"version-history":[{"count":0,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/posts\/58509\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/media\/64039"}],"wp:attachment":[{"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/media?parent=58509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/categories?post=58509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/tags?post=58509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}