简体   繁体   中英

Anaconda environment in Pycharm

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?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM