Conda set python version

Getting started with conda

Conda is a powerful package manager and environment manager that you use with command line commands at the Anaconda Prompt for Windows, or in a terminal window for macOS or Linux.

This 20-minute guide to getting started with conda lets you try out the major features of conda. You should understand how conda works when you finish this guide.

SEE ALSO: Getting started with Anaconda Navigator, a graphical user interface that lets you use conda in a web-like interface without having to enter manual commands. Compare the Getting started guides for each to see which program you prefer.

Before you start

Contents

  • Starting conda on Windows, macOS, or Linux. 2 MINUTES
  • Managing conda . Verify that Anaconda is installed and check that conda is updated to the current version. 3 MINUTES
  • Managing environments . Create environments and move easily between them. 5 MINUTES
  • Managing Python . Create an environment that has a different version of Python. 5 MINUTES
  • Managing packages . Find packages available for you to install. Install packages. 5 MINUTES
Читайте также:  Разбить строку php массив

Starting conda

../_images/anaconda-prompt.png

  • From the Start menu, search for and open «Anaconda Prompt.»

On Windows, all commands below are typed into the Anaconda Prompt window.

On macOS, all commands below are typed into the terminal window.

On Linux, all commands below are typed into the terminal window.

Managing conda

Verify that conda is installed and running on your system by typing:

Conda displays the number of the version that you have installed. You do not need to navigate to the Anaconda directory.

If you get an error message, make sure you closed and re-opened the terminal window after installing, or do it now. Then verify that you are logged into the same user account that you used to install Anaconda or Miniconda.

Update conda to the current version. Type the following:

Conda compares versions and then displays what is available to install.

If a newer version of conda is available, type y to update:

We recommend that you always keep conda updated to the latest version.

Managing environments

Conda allows you to create separate environments containing files, packages, and their dependencies that will not interact with other environments.

When you begin using conda, you already have a default environment named base . You don’t want to put programs into your base environment, though. Create separate environments to keep your programs isolated from each other.

    Create a new environment and install a package in it. We will name the environment snowflakes and install the package BioPython. At the Anaconda Prompt or in your terminal window, type the following:

conda create --name snowflakes biopython 

Conda checks to see what additional packages («dependencies») BioPython will need, and asks if you want to proceed:

conda activate only works on conda 4.6 and later versions.

For conda versions prior to 4.6, type:

Now that you are in your snowflakes environment, any conda commands you type will go to that environment until you deactivate it.

conda environments: base /home/username/Anaconda3 snowflakes * /home/username/Anaconda3/envs/snowflakes 

When the environment is deactivated, its name is no longer shown in your prompt, and the asterisk (*) returns to base. To verify, you can repeat the conda info —envs command.

Managing Python

When you create a new environment, conda installs the same Python version you used when you downloaded and installed Anaconda. If you want to use a different version of Python, for example Python 3.5, simply create a new environment and specify the version of Python that you want.

    Create a new environment named «snakes» that contains Python 3.9:

conda create --name snakes python=3.9 

conda activate only works on conda 4.6 and later versions.

For conda versions prior to 4.6, type:

Conda displays the list of all environments with an asterisk (*) after the name of the active environment:

# conda environments: # base /home/username/anaconda3 snakes * /home/username/anaconda3/envs/snakes snowflakes /home/username/anaconda3/envs/snowflakes 

The active environment is also displayed in front of your prompt in (parentheses) or [brackets] like this:

Источник

Managing Python

Conda treats Python the same as any other package, so it is easy to manage and update multiple installations.

Conda supports Python 3.8, 3.9, 3.10, and 3.11.

Viewing a list of available Python versions

To list the versions of Python that are available to install, in your terminal window or an Anaconda Prompt, run:

This lists all packages whose names contain the text python .

To list only the packages whose full name is exactly python , add the —full-name option. In your terminal window or an Anaconda Prompt, run:

conda search --full-name python 

Installing a different version of Python

To install a different version of Python without overwriting the current version, create a new environment and install the second Python version into it:

    Create the new environment:
    To create the new environment for Python 3.9, in your terminal window or an Anaconda Prompt, run:

conda create -n py39 python=3.9 anaconda

Note Replace py39 with the name of the environment you want to create. anaconda is the metapackage that includes all of the Python packages comprising the Anaconda distribution. python=3.9 is the package and version you want to install in this new environment. This could be any package, such as numpy=1.19 , or multiple packages .

Installing PyPy

To use the PyPy builds you can do the following:

conda config --add channels conda-forge conda config --set channel_priority strict conda create -n pypy pypy conda activate pypy 

Using a different version of Python

To switch to an environment that has different version of Python, activate the environment .

Updating or upgrading Python

Use the terminal or an Anaconda Prompt for the following steps.

If you are in an environment with Python version 3.4.2, the following command updates Python to the latest version in the 3.4 branch:

The following command upgrades Python to another branch—3.8—by installing that version of Python. It is not recommended, rather it is preferable to create a new environment. The resolver has to work very hard to determine exactly which packages to upgrade. But it is possible, and the command is:

© Copyright 2017, Anaconda, Inc. Revision b89a1470 .

Источник

Getting started with conda

Conda is a powerful package manager and environment manager that you use with command line commands at the Anaconda Prompt for Windows, or in a terminal window for macOS or Linux.

This 20-minute guide to getting started with conda lets you try out the major features of conda. You should understand how conda works when you finish this guide.

SEE ALSO: Getting started with Anaconda Navigator, a graphical user interface that lets you use conda in a web-like interface without having to enter manual commands. Compare the Getting started guides for each to see which program you prefer.

Before you start

Contents

  • Starting conda on Windows, macOS, or Linux. 2 MINUTES
  • Managing conda . Verify that Anaconda is installed and check that conda is updated to the current version. 3 MINUTES
  • Managing environments . Create environments and move easily between them. 5 MINUTES
  • Managing Python . Create an environment that has a different version of Python. 5 MINUTES
  • Managing packages . Find packages available for you to install. Install packages. 5 MINUTES

Starting conda

../_images/anaconda-prompt.png

  • From the Start menu, search for and open «Anaconda Prompt.»

On Windows, all commands below are typed into the Anaconda Prompt window.

On macOS, all commands below are typed into the terminal window.

On Linux, all commands below are typed into the terminal window.

Managing conda

Verify that conda is installed and running on your system by typing:

Conda displays the number of the version that you have installed. You do not need to navigate to the Anaconda directory.

If you get an error message, make sure you closed and re-opened the terminal window after installing, or do it now. Then verify that you are logged into the same user account that you used to install Anaconda or Miniconda.

Update conda to the current version. Type the following:

Conda compares versions and then displays what is available to install.

If a newer version of conda is available, type y to update:

We recommend that you always keep conda updated to the latest version.

Managing environments

Conda allows you to create separate environments containing files, packages, and their dependencies that will not interact with other environments.

When you begin using conda, you already have a default environment named base . You don’t want to put programs into your base environment, though. Create separate environments to keep your programs isolated from each other.

    Create a new environment and install a package in it. We will name the environment snowflakes and install the package BioPython. At the Anaconda Prompt or in your terminal window, type the following:

conda create --name snowflakes biopython 

Conda checks to see what additional packages («dependencies») BioPython will need, and asks if you want to proceed:

conda activate only works on conda 4.6 and later versions.

For conda versions prior to 4.6, type:

Now that you are in your snowflakes environment, any conda commands you type will go to that environment until you deactivate it.

conda environments: base /home/username/Anaconda3 snowflakes * /home/username/Anaconda3/envs/snowflakes 

When the environment is deactivated, its name is no longer shown in your prompt, and the asterisk (*) returns to base. To verify, you can repeat the conda info —envs command.

Managing Python

When you create a new environment, conda installs the same Python version you used when you downloaded and installed Anaconda. If you want to use a different version of Python, for example Python 3.5, simply create a new environment and specify the version of Python that you want.

    Create a new environment named «snakes» that contains Python 3.9:

conda create --name snakes python=3.9 

conda activate only works on conda 4.6 and later versions.

For conda versions prior to 4.6, type:

Conda displays the list of all environments with an asterisk (*) after the name of the active environment:

# conda environments: # base /home/username/anaconda3 snakes * /home/username/anaconda3/envs/snakes snowflakes /home/username/anaconda3/envs/snowflakes 

The active environment is also displayed in front of your prompt in (parentheses) or [brackets] like this:

Источник

Change the Python Version in Anaconda

Change the Python Version in Anaconda

  1. Use the conda install Command on the Anaconda Command Prompt
  2. Use the Latest Anaconda Installer
  3. Use the conda create Command on the Anaconda Command Prompt
  4. Use the conda update Command on the Anaconda Command Prompt

This article introduces various methods to change the Python version in Anaconda.

Once you change the Python version on the Anaconda command prompt, you can use the following command to display the current version of Python.

Use the conda install Command on the Anaconda Command Prompt

Use the conda install command on the Anaconda command prompt to change the Python version. Follow this example below.

conda install python=the_version> 

Use the Latest Anaconda Installer

Use the latest Anaconda installer to update the Python version. It is a graphical installer.

You will find the newer versions of Python here.

You will find the older versions of Python here.

Use the conda create Command on the Anaconda Command Prompt

If you’d like to install the new version of Python in a particular environment, you could use the conda create command.

conda create -n my_environment> python=new_version> 

Here’s another method you can follow.

conda create -n an_env python=3.5 

Post that, you need to activate the environment using the command below.

conda activate my_environment> 

You can also issue the command in the following way.

Use the conda update Command on the Anaconda Command Prompt

If you want to change the version of Python to the latest version, you can do so by utilizing conda update command. Here’s the program you can do.

Copyright © 2023. All right reserved

Источник

Оцените статью