> ## 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.

# PyCharm

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>;
};

<Note>
  These instructions refer to Anaconda Distribution exclusively, but also work with Miniconda.
</Note>

[PyCharm](https://www.jetbrains.com/pycharm/) is an <Tooltip tip="An integrated development environment. A suite of software tools that combines everything a developer needs to write and test software.">IDE</Tooltip> that integrates with Jupyter Notebook, has an interactive Python console, and supports [Anaconda](https://www.anaconda.com/download) and multiple scientific packages. PyCharm also supports creating virtual environments for Python with conda.

<Tip>
  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 Get Started with Anaconda course to learn to [create a simple Python program with PyCharm](https://learning.anaconda.com/courses/take/get-started-with-anaconda/lessons/63068075-create-a-simple-python-program-in-pycharm).
</Tip>

## Configuring a conda environment in PyCharm

Python projects often require specific setups, with access to different versions of Python and different packages and their dependencies. <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 environments</Tooltip> isolate your PyCharm projects so that each one is built and run with the exact Python specifications it requires.

You can use the `base` conda environment with a new project, create a new conda environment during project setup, or configure an existing conda environment for a new project. You can also switch conda environments within an existing project.

PyCharm offers two conda-related interpreter types:

* **Base conda**: Uses the `base` conda environment directly. This is the quickest option if you don't need a separate environment.

* **Custom environment**: Lets you create a new conda environment or select an existing one for your project.

### Using the base conda environment

To create a new project using your `base` conda environment:

<Note>
  Anaconda recommends creating a separate conda environment for each project. Using the base environment for multiple projects can cause dependency conflicts.
</Note>

1. Open PyCharm and click **New Project**.

2. In the New Project dialog, set the project location in the **Location** field.

3. Under **Interpreter type**, select **Base conda**.

4. PyCharm detects your conda installation and displays the path in the **Path to conda** field. If PyCharm does not detect conda automatically, specify the path to the conda executable (typically `<INSTALL_DIR>\Scripts\conda.exe` on Windows or `<INSTALL_DIR>/condabin/conda` on macOS/Linux).

   <Frame>
     <img src="https://mintcdn.com/anaconda-29683c67/hgx76PC52c929nfw/images/getting-started/pycharm-create-project-new-conda-env.png?fit=max&auto=format&n=hgx76PC52c929nfw&q=85&s=46d6add04d7cce47bb80c0cf8d6e2830" alt="The New Project dialog with Base conda selected as the interpreter type, showing the auto-detected path to conda" width="2582" height="906" data-path="images/getting-started/pycharm-create-project-new-conda-env.png" />
   </Frame>

5. Click **Create**.

### Using custom conda environments

You can create a new conda environment as part of the project setup, or use an existing conda environment:

1. Open PyCharm and click **New Project**.
2. In the New Project dialog, set the project location in the **Location** field.
3. Under **Interpreter type**, select **Custom environment**.

   <Tabs>
     <Tab title="New environment">
       To create a new conda environment:

       1. Under **Environment**, select **Generate new**.

       2. From the **Type** dropdown, select *Conda*.

       3. From the **Python version** dropdown, select the Python version you want.

       4. Enter your environment name in the **Name** field.

       5. PyCharm detects your conda installation and displays the path in the **Path to conda** field. If PyCharm does not detect conda automatically, specify the path to the conda executable (typically `<INSTALL_DIR>\Scripts\conda.exe` on Windows or `<INSTALL_DIR>/condabin/conda` on macOS/Linux).

              <Frame>
                <img src="https://mintcdn.com/anaconda-29683c67/hgx76PC52c929nfw/images/getting-started/pycharm-create-project-custom-conda-env.png?fit=max&auto=format&n=hgx76PC52c929nfw&q=85&s=060f3bcdda2a495ab7121aa3d8a7563f" alt="The New Project dialog with Custom environment selected, Generate new and Conda chosen as the type, showing Python version, Name, and Path to conda fields" width="2460" height="1172" data-path="images/getting-started/pycharm-create-project-custom-conda-env.png" />
              </Frame>

       6. Click **Create** to create your project and conda environment.

       7. Verify that the conda environment was created by running `conda info --envs` in <Tooltip tip="A command-line application included with Windows installations of Anaconda Distribution and Miniconda. Find it by searching 'Anaconda Prompt' in the Windows Start menu.">Anaconda Prompt</Tooltip> (Terminal on macOS/Linux):

          ```sh theme={null}
          conda info --envs
          # conda environments:
          base              *   /opt/miniconda3/
          pythonproject1        /opt/miniconda3/envs/pythonproject1
          ```

          You can also view your environments in the **Environments** tab in Anaconda Navigator.
     </Tab>

     <Tab title="Existing environment">
       To use an existing conda environment:

       1. Under **Environment**, select **Select existing**.

       2. From the **Type** dropdown, select *Conda*.

       3. PyCharm detects your conda installation and displays the path in the **Path to conda** field. If PyCharm does not detect conda automatically, specify the path to the conda executable (typically `<INSTALL_DIR>\Scripts\conda.exe` on Windows or `<INSTALL_DIR>/condabin/conda` on macOS/Linux).

       4. Select the environment from the **Environment** dropdown.

              <Note>
                If you specified the path to conda manually but don't see your environments listed, you might need to click **Reload environments**.
              </Note>

              <Frame>
                <img src="https://mintcdn.com/anaconda-29683c67/hgx76PC52c929nfw/images/getting-started/pycharm-create-project-existing-conda-env.png?fit=max&auto=format&n=hgx76PC52c929nfw&q=85&s=816b92b506f0d704baafe7385ce0807f" alt="The New Project dialog with Custom environment selected, Select existing and Conda chosen as the type, showing the Environment dropdown and Reload environments link" width="2458" height="1168" data-path="images/getting-started/pycharm-create-project-existing-conda-env.png" />
              </Frame>

       5. Click **Create** to create your project.
     </Tab>
   </Tabs>

### Switching environments within a PyCharm project

To change the conda environment associated with an ongoing project:

1. Open the PyCharm project associated with the conda environment you want to change.

2. Click the <Icon icon="gear" iconType="solid" /> settings icon in the top-right corner of the screen, then select *Settings...*.

3. In the left sidebar, select **Python** > **Interpreter**.

4. Click the **Add Interpreter** dropdown, then select *Add Local Interpreter...*.

   <Tabs>
     <Tab title="New environment">
       To create a new environment:

       1. Under **Environment**, select **Generate new**.
       2. From the **Type** dropdown, select *Conda*.
       3. From the **Python version** dropdown, select the Python version you want.
       4. Enter an environment name in the **Name** field.
       5. PyCharm detects your conda installation and displays the path in the **Path to conda** field. If PyCharm does not detect conda automatically, specify the path to the conda executable (typically `<INSTALL_DIR>\Scripts\conda.exe` on Windows or `<INSTALL_DIR>/condabin/conda` on macOS/Linux).

              <Frame>
                <img src="https://mintcdn.com/anaconda-29683c67/hgx76PC52c929nfw/images/getting-started/pycharm-switch-env.png?fit=max&auto=format&n=hgx76PC52c929nfw&q=85&s=637cbe0465566ede5aa018ff73c11fa5" alt="The Add Python Interpreter dialog with Generate new selected and Conda chosen as the type, showing Python version, Name, and Path to conda fields" width="1264" height="624" data-path="images/getting-started/pycharm-switch-env.png" />
              </Frame>
     </Tab>

     <Tab title="Existing environment">
       To use an existing environment:

       1. Under **Environment**, select **Select existing**.
       2. From the **Type** dropdown, select *Conda*.
       3. PyCharm detects your conda installation and displays the path in the **Path to conda** field. If PyCharm does not detect conda automatically, specify the path to the conda executable (typically `<INSTALL_DIR>\Scripts\conda.exe` on Windows or `<INSTALL_DIR>/condabin/conda` on macOS/Linux).
       4. Select an environment from the **Environment** dropdown.

              <Note>
                If you specified the path to conda manually but don't see your environments listed, you might need to click **Reload environments**.
              </Note>

              <Frame>
                <img src="https://mintcdn.com/anaconda-29683c67/hgx76PC52c929nfw/images/getting-started/pycharm-switch-existing-env.png?fit=max&auto=format&n=hgx76PC52c929nfw&q=85&s=7d019bdc4589f529f06a4e33803d10be" alt="The Add Python Interpreter dialog with Select existing selected and Conda chosen as the type, showing the Environment dropdown and Reload environments link" width="1272" height="628" data-path="images/getting-started/pycharm-switch-existing-env.png" />
              </Frame>
     </Tab>
   </Tabs>

5. Click **OK** to finish changing your project's environment.

## Adding a package to a project

If your project uses a package that is not in the standard Python library, you can add it to your project's conda environment with PyCharm.

The project in this example uses the `flask` package. PyCharm flags the unresolved import with a red underline.

1. Hover over the import to see the "Unresolved reference `flask`" popup.

   <Frame>
     <img src="https://mintcdn.com/anaconda-29683c67/hgx76PC52c929nfw/images/getting-started/pycharm-add-package-flask-install.png?fit=max&auto=format&n=hgx76PC52c929nfw&q=85&s=4658c34f70494ccfe9c7be446254e0f1" alt="PyCharm editor showing the Unresolved reference flask popup with an Install package flask option" width="3146" height="1482" data-path="images/getting-started/pycharm-add-package-flask-install.png" />
   </Frame>

2. Click **Install package flask** in the popup to install `flask` to the environment connected to your project.

3. After `flask` is installed, you can verify the installation in the **Python Packages** window. Click **Python Packages** in the bottom-left sidebar and search for "flask" to view the installed package.

   <Frame>
     <img src="https://mintcdn.com/anaconda-29683c67/hgx76PC52c929nfw/images/getting-started/pycharm-add-package-flask-docs.png?fit=max&auto=format&n=hgx76PC52c929nfw&q=85&s=a5ebcdc1832f6c2531d5117746fbf061" alt="The Python Packages tool window showing the flask package installed in the project environment" width="3460" height="1556" data-path="images/getting-started/pycharm-add-package-flask-docs.png" />
   </Frame>

## Adding a repository to a project

If your project requires packages from channels outside the Anaconda defaults, you can add a new repository to your PyCharm project using the **Python Packages** window.

1. In the **Python Packages** window, click <Icon icon="ellipsis-vertical" iconType="solid" /> **Options**, then select *Repositories...*.

2. In the Settings dialog under **Python > Package Repositories**, click <Icon icon="plus" iconType="regular" /> **Add**.

   <Frame>
     <img src="https://mintcdn.com/anaconda-29683c67/hgx76PC52c929nfw/images/getting-started/pycharm-add-repo.png?fit=max&auto=format&n=hgx76PC52c929nfw&q=85&s=73ccbd9dd16e8ad3d541f1137556c2b1" alt="The Settings dialog showing Python Package Repositories with fields for Name, Repository URL, and Authorization" width="2296" height="1388" data-path="images/getting-started/pycharm-add-repo.png" />
   </Frame>

3. Enter the name of the repository in the **Name** field.

4. Enter the repository URL in the **Repository URL** field.

   <Note>
     Channels on Anaconda.org use the URL `https://conda.anaconda.org/<CHANNEL>` for package repository access, not the `https://anaconda.org/<CHANNEL>` URL you see when browsing the channel on the website.
   </Note>

5. If the repository is local, select *None* for **Authorization**. Otherwise, select *Basic HTTP* and enter your username and password for the repository.

6. Click **OK**.

For repositories like conda-forge, the easiest way to install packages is to use <Tooltip tip="A command-line application included with Windows installations of Anaconda Distribution and Miniconda. Find it by searching 'Anaconda Prompt' in the Windows Start menu.">Anaconda Prompt</Tooltip> (Terminal on macOS/Linux). Activate your project's environment and install the package.

```sh theme={null}
conda activate <MY_ENV>
conda install --channel <CHANNEL_NAME> <PKG_NAME>
```

<Comments>
  Replace \<MY\_ENV> with the name of your environment.<br />
  Replace \<CHANNEL\_NAME> with the name of the channel you want to source from.<br />
  Replace \<PKG\_NAME> with the name of the package you want to install.
</Comments>

For more information on adding repositories to your PyCharm project's conda environment, see [the PyCharm documentation](https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html#custom-repositories).
