Change default environment in anaconda
Solution 1
You could add the following line to the end of your ~/.bashrc
or ~/.bash_profile
file:
source activate py34
Unfortunately, I'm not familiar with developing on Windows, but this might help? Another possibility is to use an IDE such as pycharm, which I can really recommend for developing python. There, you can change your project settings to your py34
environment.
Solution 2
On Windows:
Search for the Activate.bat file, Usually it is in
"C:\Users\Your_UserName\AppData\Local\Continuum\anaconda3\Scripts"
Open Activate.bat file in any Text Editor and Append
activate Your_Environment_Name
Save it and after that whenever you will open Anaconda Prompt Your_Environment will get Activated by default instead of base environment.
Solution 3
You can use this link to create a new env - https://stackoverflow.com/a/60820687/11383333
Once your env is created, you can use the answer mentioned by Jayesh to update the activate.bat file -
Let's say the new env name is python39, then the original line in activate.bat looks like this - @CALL "%~dp0..\condabin\conda.bat" activate %*
Update it to this - @CALL "%~dp0..\condabin\conda.bat" activate python38
Save it and restart your anaconda prompt
Admin
Updated on July 26, 2022Comments
-
Admin almost 2 years
By default, anaconda is using my
root
environment. However, I'm always using another environment calledpy34
that I activate manually. Is it possible to change the default environment fromroot
to another one?Edit: I forgot to mention that I'm working on Windows. On Unix systems adding a line to
.bashrc
is a solution of course. -
Admin about 8 yearsYes indeed - but unfortunately not on Windows.
-
Admin about 8 yearsYes, the link helps - but I still think there should be a more elegant way to change the default environment...
-
Lisa about 8 years@pomodorochris Do you use an IDE? If yes, you can set the python interpreter accordingly.
-
Lisa about 8 yearsMaybe that's something you could look into? I can really recommend pycharm! I'm pretty sure you can use it on windows, too.
-
Eryk Sun about 8 yearsYou should be aware that cmd's "AutoRun" command line (it's not just a script path) is executed every time cmd.exe runs, including every time the CRT's
system
function (i.e.os.system
) is called. So if you run a script like this you should set a sentry environment variable to keep it from running multiple times. -
Lisa about 8 years@eryksun Thanks for pointing this out. Maybe you could resolve this in a separate answer? As I said, windows is not really my specialty.
-
Eryk Sun about 8 years@Lisa, I've never used Anaconda. If it uses a shortcut to a batch file to set up the environment, pomodorochris can modify that batch file to activate the desired virtual environment. That would be preferable to modifying what every instance of cmd.exe does.
-
jrdunson about 4 yearsI know this is an older thread, but I tried updating the activate.bat, and it didn't work