How to Install Anaconda (Conda) on PyCharm?

Here’s the short summary in case you’re super busy:

To set up and use Anaconda in Pycharm, first open PyCharm, click "Create new project", click "Add Local", navigate to your desired conda environment, select python.exe, and click OK.

Let’s go into the weeds with more details next!

Adding the Anaconda Environment to PyCharm

Consider this particular resource as a “flute”, if you will, which can be used to PyCharm an Anaconda right into the environment options!

Here’s how to integrate your favorite Python environment into your favorite code editor:

1. Once you launch PyCharm and the starting screen is displayed, look for the Python version at the very bottom-right corner next to the little padlock and current color scheme.

Click on it and choose the last option – “Add Interpreter” as shown here:

2. The window illustrated below should appear.

In the left pane, the second option is “Conda Environment” which if you accepted the default install directory when you installed Anaconda, PyCharm should already have the paths filled out.

If not, you’ll have to browse to the directory where Anaconda is installed – the conda.exe should be in the Scripts directory of that folder.

See the illustration below:                                 

Other than checking the option to make the Anaconda environment available to all projects future and current, clicking OK will add Anaconda as one of the environment options.

You can change this at any time from the bottom-right corner – see Step 1.

How to Create a New Project in PyCharm Using the Anaconda Environment

  1. Launch PyCharm and select “New Project” as shown below.
  2. Enter the directory you want the new virtual environment in the top-most path labeled “Location”
  3. If not expanded, click the arrow next to “Python Interpreter”
  4. In the dropdown list shown after “New environment using”, select “Conda”
  5. In the next “Location” box, enter a directory for the project name – full path
    • The project directory should be a subdirectory of the virtual environment
    • For instance, if you have C:\MyDevs in the top “Location” box, the name for your new project may be C:\MyDevs\MyProject
  6. Select the version of Python you intend to use in the next field: “Python version”
  7. Provide the Path to conda.exe – if installed to default directories, path is supplied
  8. If Anaconda was NOT installed to the default directories, navigate to the main folder
    • The conda.exe is Located in the Scripts directory under the main folder.
    • Example: <custom dir>\anaconda3\Scripts\conda.exe
  9. Check the box to Make available to all projects – Recommended but optional
    • Leaving the option unchecked will make Anaconda only available to the newly-created virtual environment
    • Checking the option adds Anaconda as an option for all projects and virtual environments
  10. Click Create and you’re finished! The new environment will use Anaconda.
Step 1: Launch PyCharm
Step 9

Adding & Using Anaconda for Existing Projects or Virtual Environments

  1. Launch PyCharm & load existing virtual environment or project
  2. From the File menu in the top left, select “Settings” about halfway down
    • Alternatively, select the current interpreter from the bottom right-hand corner, to the left of the chosen color scheme shown.
    • Clicking the quick link to the interpreter, simply select the very last options shown “Add Interpreter”.
  3. Through the file/settings method, it should automatically scroll to Project:
    • From the left pane, select “Python Interpreter” from the expanded sections under Project: <Name> if not already selected.
  4. At the top on the right, follow the dropdown box labeled “Python Interpreter”
    • Click the gear icon at the end of the dropdown list and select “Add”
  5. A new window appears. Select “Conda” – second option – from the left pane
  6. For existing projects, select the lower radio button “Existing Environment”
  7. The path to Anaconda’s python.exe is required for “Interpreter:” Box
    • Navigate to the Conda main installation folder using the ellipses at the end of the text box and locate the python.exe file.
  8. The “Conda executable:”  is required
    • If Anaconda was installed to the default directories, this path should already be provided. Otherwise, see next substep
    • If different than default locate the Conda install directory and find the “Scripts” subdirectory – this folder contains the conda.exe file.
  9. Check or leave the last option “Make available to all projects”

This option is recommended as it simply adds the Anaconda interpreter as an option for all projects and virtual environments, future and current. This would prevent having to repeat these same steps if you plan to use Anaconda again.

Step 4 (1): Using Quick Access Link to Add Interpreter
Step 4 (2): Through File Menu & Settings
Step 9

Creating a Virtual Environment Using Anaconda via the Command Line

You can also create a virtual environment that uses Anaconda. This is particularly useful if you need to use a specific version of Python.

1. Open the command line, terminal, or the Anaconda Prompt, navigate to the location you want, and type the following command to create a new virtual environment, replacing <VE name> with your environment name and <version> with the version of Python you want to use:

conda create --name <VE name> python=<version>

This creates a clean environment so if you need to install any modules or packages, you can add them to the aforementioned command after the Python version separated by spaces.

For example:

conda create --name <VE name> python=<version> scikit pandas

Once the command finishes running, you’ll need to activate it. The command to do this is shown in the window after you run the command to create the environment:

conda <VE name> activate
  • Once you’ve activated the environment, you can open it in PyCharm. Simply choose Open from the Projects menu, navigate to the directory where you just created the new environment, and select it. PyCharm will prompt you whether or not to trust the project, obviously select Trust Project and you may want to check the option to always trust if it’s a local directory.

Potential Issues

If you encounter issues following the steps listed here, oftentimes the cause can be traced back to environment variables.

Check the environment variables set up on the system and try again.

For instance, the following error can occur when multiple Python platforms are installed, including Anaconda:

init_sys_streams: can't initialize sys standard streams

If you receive this error attempting to launch Anaconda or other Python apps, remove any environment variables on the system that point to Python interpreters – both user AND system variables, such as PYTHONPATH. Once you remove all the paths, a restart may be required. Afterwards all Python apps should launch and run normally again.