Chirag Patankar
Chirag Patankar

Reputation: 91

In Anaconda/Python how to make my Virtual Environment as default environment when starting Anaconda Prompt?

I have two Python environments in my Anaconda "base" and "image_analytics". Every time I close and start Anaconda Prompt, I can see "base" environment activated by default. I have to write "conda activate image_analytics" every time. I want image_analytics environment to get activated every time by default I restart Anaconda Prompt. Any solution? I am a beginner. Any help is appreciated.

Upvotes: 5

Views: 955

Answers (1)

FlyingTeller
FlyingTeller

Reputation: 20629

It actually quite simple, because the anaconda prompt is just a shortcut to cmd with an added call to activate the base env, which can be modified to start other envs

  1. Locate the shortcut for anaconda prompt, either by going to Start Menu->Right Clik Anaconda Prompt->Open File Location or by navigating to the equivalent on your system of C:\Users\<Username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)

  2. Open the properties of the shortcut: Right Click->Properties

  3. Modify the Target field. Original for me that activates the base env: %windir%\System32\cmd.exe "/K" C:\Users\<Username>\miniconda3\Scripts\activate.bat C:\Users\<Username>\miniconda3, which I can modify to e.g. start the py37 env: %windir%\System32\cmd.exe "/K" C:\Users\<Username>\miniconda3\Scripts\activate.bat C:\Users\<Username>\miniconda3\envs\py37. Note that I simply modified the last path in that line to point to an environment instead of base.

Upvotes: 5

Related Questions