These instructions refer to Anaconda Distribution exclusively, but also work with Miniconda.
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. isolate your PyCharm projects so that each one is built and run with the exact Python specifications it requires. You can use thebase 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
baseconda 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 yourbase conda environment:
Anaconda recommends creating a separate conda environment for each project. Using the base environment for multiple projects can cause dependency conflicts.
- Open PyCharm and click New Project.
- In the New Project dialog, set the project location in the Location field.
- Under Interpreter type, select Base conda.
-
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.exeon Windows or<INSTALL_DIR>/condabin/condaon macOS/Linux).
- 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:- Open PyCharm and click New Project.
- In the New Project dialog, set the project location in the Location field.
-
Under Interpreter type, select Custom environment.
- New environment
- Existing environment
To create a new conda environment:- Under Environment, select Generate new.
- From the Type dropdown, select Conda.
- From the Python version dropdown, select the Python version you want.
- Enter your environment name in the Name field.
-
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.exeon Windows or<INSTALL_DIR>/condabin/condaon macOS/Linux).
- Click Create to create your project and conda environment.
-
Verify that the conda environment was created by running
conda info --envsin (Terminal on macOS/Linux):You can also view your environments in the Environments tab in Anaconda Navigator.
Switching environments within a PyCharm project
To change the conda environment associated with an ongoing project:- Open the PyCharm project associated with the conda environment you want to change.
- Click the settings icon in the top-right corner of the screen, then select Settings….
- In the left sidebar, select Python > Interpreter.
-
Click the Add Interpreter dropdown, then select Add Local Interpreter….
- New environment
- Existing environment
To create a new environment:- Under Environment, select Generate new.
- From the Type dropdown, select Conda.
- From the Python version dropdown, select the Python version you want.
- Enter an environment name in the Name field.
-
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.exeon Windows or<INSTALL_DIR>/condabin/condaon macOS/Linux).
- 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 theflask package. PyCharm flags the unresolved import with a red underline.
-
Hover over the import to see the “Unresolved reference
flask” popup.
-
Click Install package flask in the popup to install
flaskto the environment connected to your project. -
After
flaskis 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.
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.- In the Python Packages window, click Options, then select Repositories….
-
In the Settings dialog under Python > Package Repositories, click Add.

- Enter the name of the repository in the Name field.
-
Enter the repository URL in the Repository URL field.
Channels on Anaconda.org use the URL
https://conda.anaconda.org/<CHANNEL>for package repository access, not thehttps://anaconda.org/<CHANNEL>URL you see when browsing the channel on the website. - If the repository is local, select None for Authorization. Otherwise, select Basic HTTP and enter your username and password for the repository.
- Click OK.

