user1946481
user1946481

Reputation: 35

conda activate env not changing file directory

I can't write (and therefore install packages) to the C:\Anaconda\envs\ folder, but even after changing the envs directories variable to point to a new path the activate command does not work.

enter image description here

Any suggestions? I looked at the activate.py script, but don't see an error message that matches mine or where to change the file path

Working in Windows-64. Not in powershell. Not sure how to manually edit my PATH. Already looked at Conda virtual envinment not changing under Windows - similar issue

I also didn't have success with this similar post: How to activate an Anaconda environment

The activate.bat file is what is generating the error at line 24, but I'm not sure how to fix it. Seems like the ANACONDA_ENVS is set in line 4, but I have no idea what ANACONDA_ENVS=%%~fi means

Upvotes: 0

Views: 2777

Answers (4)

user1946481
user1946481

Reputation: 35

copying the activate.bat file fixed it for me

Upvotes: 0

alfa33333
alfa33333

Reputation: 1

To solve this I modified the header of the activate.bat copy from "my_root\Scripts" folder and added fixed path:

 for /f "delims=" %%i in ("%~dp0..\envs") do (
    set ANACONDA_ENVS=C:\Users\yourusername\.conda\envs
)

This means that I had to execute in the prompt

C:\Users\yourusername\.conda\envs\Scripts\activate my_root

specifying the full path.

Upvotes: 0

James
James

Reputation: 36608

Try adding a new path variable to your .condarc file (NOTE: this assumes %USERPROFILE% is your C:\Users\USERNAME directory used above)

conda config --prepend envs_dirs %USERPROFILE%/.conda/envs

Close and reopen CMD and try

activate my_root

Upvotes: 1

Mike Müller
Mike Müller

Reputation: 85442

Type:

activate C:\Users\N029810\.conda\envs\my_root

The prompt should change to:

(my_root)

Now, you should be able to install packages:

conda install <apackage>

Upvotes: 0

Related Questions