Change default environment in anaconda
Asked Answered
L

3

10

By default, anaconda is using my root environment. However, I'm always using another environment called py34 that I activate manually. Is it possible to change the default environment from root 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.

Litigate answered 23/2, 2016 at 10:43 Comment(0)
D
4

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.

Deplume answered 23/2, 2016 at 11:9 Comment(7)
Yes indeed - but unfortunately not on Windows.Litigate
Yes, the link helps - but I still think there should be a more elegant way to change the default environment...Litigate
@pomodorochris Do you use an IDE? If yes, you can set the python interpreter accordingly.Deplume
Maybe that's something you could look into? I can really recommend pycharm! I'm pretty sure you can use it on windows, too.Deplume
You 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.Surgeonfish
@eryksun Thanks for pointing this out. Maybe you could resolve this in a separate answer? As I said, windows is not really my specialty.Deplume
@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.Surgeonfish
Z
1

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.

Zonate answered 26/12, 2018 at 8:1 Comment(1)
I know this is an older thread, but I tried updating the activate.bat, and it didn't workStodder
A
1

You can use this link to create a new env - https://mcmap.net/q/158063/-upgrade-to-python-3-8-using-conda

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

Aphonia answered 5/6, 2020 at 14:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.