> ## Documentation Index
> Fetch the complete documentation index at: https://anaconda.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Environments

export const TroubleshootSolution = ({children}) => <>
    <hr className="my-3 w-full" />
    <details className="mt-3">
      <summary className="cursor-pointer font-semibold text-base mb-1">
        Solution
      </summary>
      <div className="mt-2 ml-4" data-component-part="step-content">
        {children}
      </div>
    </details>
  </>;

export const TroubleshootCause = ({children}) => <details className="mt-3 mb-2">
    <summary className="cursor-pointer font-semibold text-base mb-1">
      Cause
    </summary>
    <div className="mt-2 ml-4" data-component-part="step-content">
      {children}
    </div>
  </details>;

export const TroubleshootTitle = ({children}) => <>
    <p className="m-0 font-semibold text-xl leading-tight mb-2" role="heading" aria-level={3}>
      {children}
    </p>
    <hr className="my-3 w-full" />
  </>;

export const Troubleshoot = ({children}) => <div className="callout my-4 px-5 py-4 overflow-hidden rounded-2xl flex gap-3 border troubleshoot-admonition dark:troubleshoot-admonition" data-callout-type="troubleshoot">
    <div className="mt-0.5 w-4">
      <svg width="14" height="14" viewBox="0 0 640 640" fill="currentColor" className="w-4 h-4" aria-label="Troubleshoot">
        <path d="M541.4 162.6C549 155 561.7 156.9 565.5 166.9C572.3 184.6 576 203.9 576 224C576 312.4 504.4 384 416 384C398.5 384 381.6 381.2 365.8 376L178.9 562.9C150.8 591 105.2 591 77.1 562.9C49 534.8 49 489.2 77.1 461.1L264 274.2C258.8 258.4 256 241.6 256 224C256 135.6 327.6 64 416 64C436.1 64 455.4 67.7 473.1 74.5C483.1 78.3 484.9 91 477.4 98.6L388.7 187.3C385.7 190.3 384 194.4 384 198.6L384 240C384 248.8 391.2 256 400 256L441.4 256C445.6 256 449.7 254.3 452.7 251.3L541.4 162.6z" />
      </svg>
    </div>
    <div className="prose min-w-0 w-full">{children}</div>
  </div>;

export const Comments = ({children}) => {
  return <div class="my-4 px-5 py-4 overflow-hidden rounded-2xl flex gap-3 border border-zinc-500/20 bg-zinc-50/50 dark:border-zinc-500/30 dark:bg-zinc-500/10" data-callout-type="comments">
      <div class="w-4">
        <svg width="14" height="14" viewBox="0 0 640 640" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" aria-label="Comments">
            <path d="M320 112C434.9 112 528 205.1 528 320C528 434.9 434.9 528 320 528C205.1 528 112 434.9 112 320C112 205.1 205.1 112 320 112zM320 576C461.4 576 576 461.4 576 320C576 178.6 461.4 64 320 64C178.6 64 64 178.6 64 320C64 461.4 178.6 576 320 576zM280 400C266.7 400 256 410.7 256 424C256 437.3 266.7 448 280 448L360 448C373.3 448 384 437.3 384 424C384 410.7 373.3 400 360 400L352 400L352 312C352 298.7 341.3 288 328 288L280 288C266.7 288 256 298.7 256 312C256 325.3 266.7 336 280 336L304 336L304 400L280 400zM320 256C337.7 256 352 241.7 352 224C352 206.3 337.7 192 320 192C302.3 192 288 206.3 288 224C288 241.7 302.3 256 320 256z" />
        </svg>
      </div>
      <div class="text-sm prose min-w-0 w-full">
        {children}
      </div>
    </div>;
};

export const Danger = ({children}) => {
  return <div class="callout my-4 px-5 py-4 overflow-hidden rounded-2xl flex gap-3 border danger-admonition dark:danger-admonition" data-callout-type="danger">
      <div class="mt-0.5 w-4">
        <svg width="14" height="14" viewBox="0 0 14 14" fill="rgb(239, 68, 68)" xmlns="http://www.w3.org/2000/svg" class="w-4 h-4 text-sky-500" aria-label="Danger">
          <path fill-rule="evenodd" clip-rule="evenodd" d="M7 1.3C10.14 1.3 12.7 3.86 12.7 7C12.7 10.14 10.14 12.7 7 12.7C5.48908 12.6974 4.0408 12.096 2.97241 11.0276C1.90403 9.9592 1.30264 8.51092 1.3 7C1.3 3.86 3.86 1.3 7 1.3ZM7 0C3.14 0 0 3.14 0 7C0 10.86 3.14 14 7 14C10.86 14 14 10.86 14 7C14 3.14 10.86 0 7 0ZM8 3H6V8H8V3ZM8 9H6V11H8V9Z"></path>
        </svg>
      </div>
      <div class="text-sm prose min-w-0 w-full">
        {children}
      </div>
    </div>;
};

Environments in conda are self-contained, isolated spaces where you can install specific versions of software <Tooltip tip="Software files and information about the software, such as its name, version, and description, bundled into a file that can be installed and managed by a package manager.">packages</Tooltip>, including dependencies, libraries, and Python versions. This isolation helps avoid conflicts between package versions and ensures that your projects have the exact libraries and tools they need. For more information on environments, see our [environments concepts page](/getting-started/concepts/what-is-an-environment).

## Working with environments

For convenience, the most common actions users take when managing environments are detailed here. For a full list of actions and more comprehensive guide, see [Manage environments](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html) in the official conda documentation. Alternatively, follow along with our [Getting started with conda environments](https://www.anaconda.com/blog/getting-started-with-conda-environments) tutorial on Anaconda.com.

<Tip>
  If you prefer to create and manage your environments via our graphical interface, Navigator, see [Managing environments](/tools/anaconda-navigator/tutorials/manage-environments).

  ***

  More of a visual learner? [Sign in to Anaconda.com](https://auth.anaconda.com/ui/login?return_to=https://anaconda.com/app/) and enroll in our free [Anaconda Environments](https://learning.anaconda.com/courses/take/simplifying-python-environment-set-up/lessons/67414209-why-anaconda) course.
</Tip>

### Creating an environment

Create a <Tooltip tip="An isolated folder containing specific conda packages and dependencies that won't interfere with other projects. Each environment maintains its own versions of libraries and packages, so changes in one environment don't affect others.">conda environment</Tooltip> by opening [Anaconda Prompt](/reference/glossary#anaconda-prompt) (Terminal on macOS/Linux) and following the steps for your use case below:

<Tabs>
  <Tab title="Creating a new environment">
    The following command creates a new environment and downloads the specified packages and their dependencies:

    ```sh theme={null}
    conda create --name <ENV_NAME> <PACKAGE>=<VERSION> <PACKAGE> <PACKAGE>
    ```

    <Comments>
      Replace \<ENV\_NAME> with a name for your environment.<br />
      Replace each \<PACKAGE> with the name of your desired packages.<br />
      Replace \<VERSION> with your desired version (optional).
    </Comments>

    ```sh Example environment creation command theme={null}
    conda create --name myenv python=3.11 beautifulsoup4 docutils jinja2=3.1.4 wheel
    ```

    <Accordion title="Example version matching inputs">
      Version matching utilizes [MatchSpec](https://docs.conda.io/projects/conda/en/latest/dev-guide/api/conda/models/match_spec/index.html#conda.models.match_spec.MatchSpec) Protocol. Below are some examples for specifying versions for packages when creating an environment. If you do not specify a package version, conda will attempt to install the latest version of the package from its available <Tooltip tip="A location (URL or file path) in a repository where conda looks for packages.">channels</Tooltip>.

      * `python=3.12.1` - Matches the package with the exact name and version specified.

      * `python>=3.11` - Matches any version of the package that is greater than or equal to the version specified.

      * `python<=3.12` - Matches any version of the package that is less than or equal to the version specified.

      * `python>3.10,<3.12` - Matches any version of the package between the specified versions, but excludes the specified versions.

      * `python>=3.10,<=3.12` - Matches any version of the package between the specified versions, including the specified versions.

      * `python[version='3.12.*']` - Matches any version of the python package that starts with 3.12.
    </Accordion>

    <Note>
      It is best practice to install all of the packages that you need in your environment in a single command. This reduces the risk of dependency conflicts or broken environments.
    </Note>
  </Tab>

  <Tab title="Creating an environment from a `.yml` file">
    If someone has shared an environment with you, or you have exported a .yml file to recreate your environment on a new machine, run the following command from the directory containing the .yml file:

    ```sh theme={null}
    conda env create --file environment.yml
    ```

    <Note>
      The first line of the file sets the environment's name. For more information, see [Creating an environment file manually](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#create-env-file-manually).
    </Note>
  </Tab>
</Tabs>

<Accordion title="Environment registration">
  When you create an environment, conda <Tooltip tip="Adds the full path to the directory containing the environment.">registers</Tooltip> it to the `environments.txt` file, which is located here:

  <Tabs>
    <Tab title="Windows">
      `%USERPROFILE%\.conda\environments.txt`
    </Tab>

    <Tab title="macOS/Linux">
      `~/.conda/environments.txt`
    </Tab>
  </Tabs>

  <Note>
    `conda --info envs` uses the `environments.txt` file to show all existing environments on your machine, even those outside the base install directory.
  </Note>
</Accordion>

### Environment locations

By default, conda creates environments in the following locations, depending on your operating system and how you've installed conda:

| Operating System | Installer                      | Default Environment Location                                                                           |
| :--------------- | :----------------------------- | :----------------------------------------------------------------------------------------------------- |
| Windows          | Graphical installer (`.exe`)   | <ul><li>`C:\Users\<USERNAME>\anaconda3\envs\`</li><li>`C:\Users\<USERNAME>\miniconda3\envs\`</li></ul> |
| macOS            | Graphical installer (`.pkg`)   | <ul><li>`/opt/anaconda3/envs/`</li><li>`/opt/miniconda3/envs/`</li></ul>                               |
| macOS            | Command line installer (`.sh`) | <ul><li>`/anaconda3/envs/`</li><li>`/miniconda3/envs/`</li></ul>                                       |
| Linux            | Command line installer (`.sh`) | <ul><li>`/anaconda3/envs/`</li><li>`/miniconda3/envs/`</li></ul>                                       |

You can specify the path where you want the environment to be created by including the `--prefix` command when creating an environment, or by updating your `.condarc` file to contain the `envs_dirs:` key.

```sh Example .condarc configuration highlight={5,6} theme={null}
channels:
  - defaults
default_channels:
  - https://repo.anaconda.com/pkgs/main
envs_dirs:
  - /Users/<USER>/conda-envs
```

### Activating an environment

Because environments are isolated spaces, you can only work with one at a time. Selecting an environment to work with is called activating it.

Activate an environment by running the following command:

```sh theme={null}
conda activate <ENV_NAME>
```

<Comments>
  Replace \<ENV\_NAME> with the name of the environment you want to activate.
</Comments>

### Switching between environments

When you're ready to switch between projects, simply activate the environment of your other project. Activating a different environment will deactivate your current one.

1. (Optional) View a list of all your environments by running the following command:

   ```sh theme={null}
   conda info --envs
   ```

2. To switch to a different environment, activate it by running the following command:

   ```sh theme={null}
   conda activate <ENV_NAME>
   ```

   <Comments>
     Replace \<ENV\_NAME> with the name of the environment you want to switch to.
   </Comments>

### Locking an environment

The most reliable way to ensure your project remains reproducible indefinitely is to "lock" its environment. Locking an environment creates a fully specified environment, one that has all packages used in the project and their dependencies configured to a specific version. This ensures that your project will be reproduced exactly as it was initially configured, because there will never be an unexpected update or change if new package dependencies are released.

Locking your project requires the `conda-project` package to be installed in the environment you want to lock. Install the package by running the following commands:

```sh theme={null}
conda activate <ENV>
conda install conda-project
```

<Comments>
  Replace \<ENV> with the environment you want to lock.
</Comments>

If your project doesn't contain an `environment.yml` file, create one by running the following command:

```sh theme={null}
conda-project init
```

You can then lock your project's environment by running the following command:

```sh theme={null}
conda-project lock
```

Locking your project produces a `conda-lock.default.yml` file that you can export to share with others.

### Sharing an environment

Sharing your environment with someone else allows them to use conda to [recreate your environment](#creating-an-environment) on their machine.

To share an environment and its software packages, you must export your environment's configurations into a `.yml` file.

<Warning>
  Simply copying your Anaconda or Miniconda files over to a new directory or another machine will not recreate the environment. You must export the environment as a whole.
</Warning>

#### Exporting the environment configuration `.yml` file

<Danger>
  If you already have an environment configuration `.yml` file in your current directory, it will be overwritten during the export process.
</Danger>

1. Activate the environment you want to export by running the following command:

   ```sh theme={null}
   conda activate <ENV_NAME>
   ```

   <Comments>
     Replace \<ENV\_NAME> with the name of the environment you want exported.
   </Comments>

2. Export the environment by running the following command:

   ```sh theme={null}
   conda env export > environment.yml
   ```

   <Note>
     The `environment.yml` file populates in your current working directory.

     ***

     This operation includes both the environment's conda and pip packages.
   </Note>

3. Share the exported environment configuration `.yml` file with another user.

### Deactivating an environment

It is best practice to deactivate your environment when you are finished working in it.

To deactivate your active environment, run the following command:

```sh theme={null}
conda deactivate
```

<Note>
  When you deactivate an environment, conda returns to the previously activated environment.

  For example, if you run `conda activate my_env1`, followed by `conda activate my_env2`, and then run `conda deactivate`, conda returns to the `my_env1` environment.
</Note>

### Removing an environment

To remove an environment, run the following command:

```sh theme={null}
conda remove --name <ENV_NAME> --all
```

<Note>
  Running `conda remove` deletes and <Tooltip tip="Removes the environment path from the list of known environments in environments.txt.">deregisters</Tooltip> your environment.
</Note>

<Warning>
  If, for any reason, you need to delete an environment directory manually, *don't use your file explorer*. If you do, you'll remove the environment's contents and free up space on your machine, but leave the environment path listed in your `environments.txt` file (see [Environment registration](/getting-started/working-with-conda/environments#creating-an-environment)).

  To manually delete and deregister an environment directory properly, run one of the following commands, depending on your operating system and conda installation:

  <Tabs>
    <Tab title="Windows">
      <CodeGroup>
        ```sh Anaconda Distribution theme={null}
        C:\Users\<YOUR_USERNAME>\anaconda3\_conda constructor uninstall --prefix <PATH_TO_ENV_DIRECTORY>
        ```

        ```sh Miniconda theme={null}
        C:\Users\<YOUR_USERNAME>\miniconda3\_conda constructor uninstall --prefix <PATH_TO_ENV_DIRECTORY>
        ```
      </CodeGroup>

      <Comments>
        Replace \<YOUR\_USERNAME> with your Windows username.<br />
        Replace \<PATH\_TO\_ENV\_DIRECTORY> with the path to the directory that contains the environments.
      </Comments>
    </Tab>

    <Tab title="macOS/Linux">
      <CodeGroup>
        ```sh Anaconda Distribution theme={null}
        ~/anaconda3/_conda constructor uninstall --prefix <PATH_TO_ENV_DIRECTORY>
        ```

        ```sh Miniconda theme={null}
        ~/miniconda3/_conda constructor uninstall --prefix <PATH_TO_ENV_DIRECTORY>
        ```
      </CodeGroup>

      <Comments>
        Replace \<PATH\_TO\_ENV\_DIRECTORY> with the path to the directory that contains the environments.
      </Comments>
    </Tab>
  </Tabs>
</Warning>

## Troubleshooting

<Troubleshoot>
  <TroubleshootTitle>
    ### command not found: conda
  </TroubleshootTitle>

  <TroubleshootCause>
    The `command not found: conda` error occurs when your command line interface (CLI) can't find the conda command in order to use it. This might be because:

    * You don't have conda properly initialized.
    * You have set `auto_activate_base` to `false`.
    * You're using a shell that conda doesn't support.
    * Conda is not installed or the install was incomplete or corrupted.

    <Note>
      These issues primarily occur on macOS/Linux computers. Anaconda Distribution and Miniconda installations on Windows include [Anaconda Prompt](/reference/glossary#anaconda-prompt), which opens with conda initialized by default.
    </Note>
  </TroubleshootCause>

  <TroubleshootSolution>
    <AccordionGroup>
      <Accordion title="Initialize conda in your shell">
        If you recently installed Anaconda Distribution or Miniconda, make sure you closed and reopened your CLI to make conda's initialization take effect.

        <Tip>
          If you don't want to close your CLI, you can also use one of the following `source` commands to refresh your shell:

          <CodeGroup>
            ```sh bash theme={null}
            source ~/.bashrc
            ```

            ```sh zsh theme={null}
            source ~/.zshrc
            ```

            ```sh fish theme={null}
            source ~/.config/fish/config.fish
            ```

            ```sh cshrc theme={null}
            source ~/.cshrc
            ```

            ```sh xonshrc theme={null}
            source ~/.xonshrc
            ```
          </CodeGroup>

          <Comments>
            Use the command that matches your shell.
          </Comments>
        </Tip>

        You can also initialize conda directly from its `bin` directory:

        <CodeGroup>
          ```sh Initialization command theme={null}
          <PATH_TO_CONDA>/bin/conda init
          ```

          ```sh Examples theme={null}
          miniconda3/bin/conda init
          /opt/miniconda3/bin/conda init
          anaconda3/bin/conda init
          /opt/anaconda3/bin/conda init
          ```
        </CodeGroup>

        <Comments>
          Replace \<PATH\_TO\_CONDA> with a path to your conda installation.
        </Comments>
      </Accordion>

      <Accordion title="Set auto_activate_base to true">
        To see the value for `auto_activate_base`, run the following command:

        ```sh theme={null}
        conda config --describe auto_activate_base
        ```

        If your terminal returns `false`, this means that conda is not automatically activating your base environment when you start a new shell. This behavior emulates your system Python, and some users prefer to have their conda environment be inactive until they need it. However, this is not conda's default behavior after installation.

        To change the value of `auto_activate_base` to `true`, run the following command:

        ```sh theme={null}
        conda config --set auto_activate_base true
        ```

        If you have `auto_activate_base` set as `false`, the conda command will still be available as a shell function, but your base environment will not be active when a new shell is started. To activate your base environment, run `conda activate`.
      </Accordion>

      <Accordion title="Use a shell that conda supports">
        For information on which shells conda supports, see [Conda activate](https://docs.conda.io/projects/conda/en/stable/dev-guide/deep-dives/activation.html#conda-activate) in the official conda documentation.
      </Accordion>

      <Accordion title="Verify your installation of conda">
        If you have tried to initialize conda in your shell but it didn't work, try uninstalling and reinstalling [Anaconda Distribution](/getting-started/anaconda/main) or [Miniconda](/getting-started/miniconda/main).

        <Tip>
          Make sure that you say yes to the initialization option, and, if installing from the CLI, reinitialize your shell by restarting it or using its `source` command. For more information, see [Initialize conda in your shell](#initialize-conda-in-your-shell).
        </Tip>
      </Accordion>
    </AccordionGroup>
  </TroubleshootSolution>
</Troubleshoot>

<Troubleshoot>
  <TroubleshootTitle>
    ### DirectoryNotACondaEnvironmentError: The target directory exists, but it is not a conda environment
  </TroubleshootTitle>

  <TroubleshootCause>
    This error means that you don't have a conda environment currently active. You might have used `conda deactivate` while in your `base` environment and deactivated conda.
  </TroubleshootCause>

  <TroubleshootSolution>
    Activate your `base` environment or another environment:

    ```sh theme={null}
    # Activate your base environment
    conda activate

    # Activate an environment by name
    conda activate <ENV_NAME>
    ```

    <Comments>
      Replace \<ENV\_NAME> with the name of the environment.
    </Comments>
  </TroubleshootSolution>
</Troubleshoot>

<Troubleshoot>
  <TroubleshootTitle>
    ### PackagesNotFoundError: The following packages are not available from current channels
  </TroubleshootTitle>

  <TroubleshootCause>
    The `PackagesNotFoundError` occurs when conda cannot find the requested packages in any of your currently configured channels in order to install or update it. This might be because:

    * The package name is misspelled.
    * The package doesn't exist in the channels included in your conda configuration file (`.condarc`).
    * The package is not available for your operating system or architecture.
  </TroubleshootCause>

  <TroubleshootSolution>
    <AccordionGroup>
      <Accordion title="Verify your command syntax">
        Verify that your package name is spelled correctly and that your command contains no syntax errors. For more information about command syntax, see [Using conda install](/getting-started/working-with-conda/packages/install-packages#using-conda-install).
      </Accordion>

      <Accordion title="Install from the package's details page">
        If you're unsure what the correct command to install the package is, you can find it on the package's details page.

        Search [Anaconda.org](https://anaconda.org) or your [Anaconda Platform channels](/anaconda-platform/self-hosted/latest/user/package#searching-for-packages) for your preferred package, and view its details. Each package's details page provides a copyable command to install the package from that channel. Run that command to install the package in your currently active environment.

        <Warning>
          Remember to pay close attention to the command's syntax! The command you copy might not be the exact command you want to run, depending on your use case. Anaconda.org uses the double-colon syntax for channel specification, while Anaconda Platform uses the channel flag syntax by default. For more information, see [Installing packages from a specific channel](/getting-started/working-with-conda/channels#installing-packages-from-a-specific-channel).
        </Warning>
      </Accordion>

      <Accordion title="Add the missing channel to your .condarc file">
        [Add the missing channel to your .condarc file](/getting-started/working-with-conda/channels#managing-channels). However, keep in mind that any channels listed in the `channels:` section of your `.condarc` file will be searched by conda every time you install a new package.
      </Accordion>

      <Accordion title="Verify the package is compatible with your system architecture">
        Check your system architecture to determine if the package is compatible. This information is found under `platform:` in your `conda info` output.

        ```sh theme={null}
        conda info
        ```

        Conda restricts searches to packages that are compatible with your system architecture. If the package you're looking for is not available for your system architecture, it is not listed in conda's package search results.
      </Accordion>
    </AccordionGroup>
  </TroubleshootSolution>
</Troubleshoot>
