Unable to activate environment - prompted to Run 'conda init' before 'conda activate' but it doesn't work

Running Bash in Cmder on Windows 10. I am trying to activate a new virtual environment but keep getting told to run ‘conda init’ before ‘conda activate’. I’ve tried running conda init but I keep getting prompted to do it again.

I’m guessing that it might have something to do with how I installed miniconda. I followed the instructions here which specifically states:

“On Windows, you’ll be asked if you want to add Miniconda to your PATH variable. Although it recommends that you do not do this, DO add it to your PATH. This will be important when we change how our command line works.”

But when I read up on the conda documentation here it states:

“When installing Anaconda, you have the option to “Add Anaconda to my PATH environment variable.” This is not recommended because it appends Anaconda to PATH. When the installer appends to PATH, it does not call the activation scripts.”

I’m guessing that this is the issue but I don’t know of a work around (if one is needed).

Actions and Errors below:

I create my environment:

conda create --name test_env

The environment is created and then I am told to:

# To activate this environment, use
#
#     $ conda activate test_env
#
# To deactivate an active environment, use
#
#     $ conda deactivate

I attempt to activate:

conda activate test_env

Ouput

CondaError: Run 'conda init' before 'conda activate'

I run ‘conda init’:

λ conda init
no change     C:\Users\Username\miniconda3\Scripts\conda.exe
no change     C:\Users\Username\miniconda3\Scripts\conda-env.exe
no change     C:\Users\Username\miniconda3\Scripts\conda-script.py
no change     C:\Users\Username\miniconda3\Scripts\conda-env-script.py
no change     C:\Users\Username\miniconda3\condabin\conda.bat
no change     C:\Users\Username\miniconda3\Library\bin\conda.bat
no change     C:\Users\Username\miniconda3\condabin\_conda_activate.bat
no change     C:\Users\Username\miniconda3\condabin\rename_tmp.bat
no change     C:\Users\Username\miniconda3\condabin\conda_auto_activate.bat
no change     C:\Users\Username\miniconda3\condabin\conda_hook.bat
no change     C:\Users\Username\miniconda3\Scripts\activate.bat
no change     C:\Users\Username\miniconda3\condabin\activate.bat
no change     C:\Users\Username\miniconda3\condabin\deactivate.bat
modified      C:\Users\Username\miniconda3\Scripts\activate
modified      C:\Users\Username\miniconda3\Scripts\deactivate
modified      C:\Users\Username\miniconda3\etc\profile.d\conda.sh
modified      C:\Users\Username\miniconda3\etc\fish\conf.d\conda.fish
no change     C:\Users\Username\miniconda3\shell\condabin\Conda.psm1
modified      C:\Users\Username\miniconda3\shell\condabin\conda-hook.ps1
no change     C:\Users\Username\miniconda3\Lib\site-packages\xontrib\conda.xsh
modified      C:\Users\Username\miniconda3\etc\profile.d\conda.csh
no change     C:\Users\Username\Documents\WindowsPowerShell\profile.ps1
modified      HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun

==> For changes to take effect, close and re-open your current shell. <==

I exit out of the shell, reopen and run:

conda activate test_env

And again get

CondaError: Run 'conda init' before 'conda activate'

I have tried executing these steps in various orders and closing the shell vs not but I am stuck in the same loop.

How can I get activate my environments if miniconda is installed to the User PATH?

1 Like

Please restart your shell and open it again in your shell, then your conda will be activated.

conda init needs shell name sometimes

if using zsh,

run:

conda init zsh

exit out of the shell, reopen and run:

conda activate test_env

2 Likes

Try this,
source activate base
and then,
conda activate my_env
It works !!!

This worked for me. Using oh-my-zsh and hyper on macOS.

I have the same issue. Have you already solved it?

ajaypunna9342 You are a genius. It worked. I am copy and pasting that to a doc all by itself and leaving on my desktop!

Well you can run this command in shell “Set-ExecutionPolicy RemoteSigned”
it will change the execution policy to RemoteSigned.
Hope this works for you