How to activate different anaconda environment from powershell

你。 提交于 2020-01-22 08:54:08

问题


I have two environments in anaconda, namely: root, 2env. When I open anaconda prompt, I can switch from root to 2env by typing: activate 2env. I also have conda in my powershell, but when I open powershell and try to run conda activate 2env it gives the following error:

CommandNotFoundError: 'activate'

Any suggestions on how to fix this?


回答1:


Although Conda previously did not support PowerShell, this is now resolved in Conda 4.6.

After adding Anaconda3/Scripts/ to your PATH variable, you should be able to initialize Conda for use with powershell with:

conda init powershell

Afterwards, you can use conda normally:

conda activate base



回答2:


I found this command while using vs code & cmd /k "activate <env> & powershell" . It is working




回答3:


I found this solution:

I've been building on BCSharp's excellent work at my own repo (currently on PR).

Just do: conda install -n root -c pscondaenvs pscondaenvs

You need Conda 4.1 or above (check with conda info conda) - otherwise please install the latest version.

Behavior is exactly like CMD - use activate or deactivate appropriately. It's completely backwards compatible and will also launch both .ps1 and .bat activate.d/deactivate.d scripts.

from https://github.com/conda/conda/issues/626#issuecomment-346224990 has worked really well for me.




回答4:


I have been battling this issue for a while. I found a solution by using a batch script and calling call activate %env%. I hope this can help somebody.




回答5:


Here is a work around - start cmd shell . Run - activate . Check - conda env list . Start powershell - powershell .



来源:https://stackoverflow.com/questions/47800794/how-to-activate-different-anaconda-environment-from-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!