Drew
Drew

Reputation: 141

conda activate on powershell

Fresh install of conda. I'm trying to activate an environment (any environment) and I get the following

(base) PS C:\Users\AndrewBergan> conda activate test123

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "C:\Users\AndrewBergan\AppData\Local\Continuum\anaconda3\lib\site-packages\conda\cli\main.py", line 138, in main
        return activator_main()
      File "C:\Users\AndrewBergan\AppData\Local\Continuum\anaconda3\lib\site-packages\conda\activate.py", line 940, in main
        print(activator.execute(), end='')
      File "C:\Users\AndrewBergan\AppData\Local\Continuum\anaconda3\lib\site-packages\conda\activate.py", line 173, in execute
        return getattr(self, self.command)()
      File "C:\Users\AndrewBergan\AppData\Local\Continuum\anaconda3\lib\site-packages\conda\activate.py", line 150, in activate
        builder_result = self.build_activate(self.env_name_or_prefix)
      File "C:\Users\AndrewBergan\AppData\Local\Continuum\anaconda3\lib\site-packages\conda\activate.py", line 275, in build_activate
        return self._build_activate_stack(env_name_or_prefix, False)
      File "C:\Users\AndrewBergan\AppData\Local\Continuum\anaconda3\lib\site-packages\conda\activate.py", line 332, in _build_activate_stack
        self._replace_prefix_in_path(old_conda_prefix, prefix))
      File "C:\Users\AndrewBergan\AppData\Local\Continuum\anaconda3\lib\site-packages\conda\activate.py", line 550, in _replace_prefix_in_path
        assert last_idx is not None
    AssertionError

What am I doing wrong?

Upvotes: 2

Views: 9810

Answers (4)

Amandeep S
Amandeep S

Reputation: 1

I was too struggling with this trouble for a long time but couldn't find any solution online. But I found it at last. This is occurring because Windows PowerShell is not allowed to run local PowerShell scripts. It can be enabled in developer settings.

On windows 10

Settings > Update & Security > For developers >  Enable PowerShell to run local PowerShell scripts without signing in.

see where to enable

Upvotes: 0

Ken Cloud
Ken Cloud

Reputation: 933

conda start to support Powershell in version 4.6. upgrade your conda, then run this:

conda init

you should be fine then.

Upvotes: 3

yuhaoooo
yuhaoooo

Reputation: 61

you can just update conda using following code

conda update -n base conda

Because conda 4.6.14 fixed this problem.

Upvotes: 4

Drew
Drew

Reputation: 141

Turns out for some reason Continuum/anaconda3/Library/bin did not get added to my path. Adding this fixed the problem.

Edit: As noted in the comment below, other modifications to your path might be needed. I was able to determine what was missing from my path by adding a couple print statements to activate.py and comparing the output from the conda bash window and powershell.

Upvotes: 4

Related Questions