Anaconda environment in Pycharm

11,516

Solution 1

You should not activate the environment on every run. You need to define the interpreter for the project. It will take a couple of seconds to parse the installed packages in that environment and later it will be fast.

https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html#project-interpreter

I wonder if there is something special in the packages you have in your environment. Five seconds is not normal.

Have you tried creating a new environment from pycharm?

https://www.jetbrains.com/help/pycharm/conda-support-creating-conda-environment.html

and later adding the packages that you really need for that project?

Solution 2

Looks like I'm not the first one experiencing this. A cool guy named Guilherme Melo created wrappers which you can use as an replacement for python interpreter in Pycharm. These wrappers than handle environment activation in a much faster way.

Just follow his advices here.

Basically all you need is to install a package called conda-wrappers into you conda environment a then replace the interpreter in Pycharm.

conda create -n test python
source activate test
conda install -c conda-forge conda-wrappers

Works in Windows too. So instead of <env>/python.exe you should select <env>/Scripts/wrappers/conda/python.bat.

That said, I consider this to rather be a workaround for a very slow conda activation script - would be nice to have that handled in a first place.

Share:
11,516
dreo
Author by

dreo

Updated on June 04, 2022

Comments

  • dreo
    dreo almost 2 years

    I am trying to use Anaconda environment as an interpreter in Pycharm.

    It actually works, but it's extremely slow - even running a single line "hello world" takes like 5 sec.

    I guess the reason is Pycharm trying to activate the environment before every execution of the script and activation in Anaconda is generally slow (at least from my experience).

    The execution speed is ok when using Anaconda root env. or when using virtualenv. Any idea/workaround how to speed it up?