Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a conda environment shortcut on Windows

With Anaconda installed I got a anaconda base shortcut on Windows startmanu. To open the virtualenv I created (e.g., myenv), I have to click the anaconda base and type in activate myenv in the opened cmd window.

How can I create a shortcut to get to myenv with one-click, without open-and-typing like the above?

I've tried to create a copy of the base shortcut and change its command property i.e., %windir%\System32\cmd.exe "/K" C:\Programs\anaconda3\Scripts\activate.bat C:\Programs\anaconda3\envs\myenv. It does open the myenv cmdline, but seemed lost some buildin command,like conda.

I guess I need a little bit help on Windows bat skills.

like image 311
John Wang Avatar asked May 27 '18 12:05

John Wang


People also ask

How do you create a conda environment path?

To permanently include packages or folder into the PYTHONPATH of an Anaconda environment, activate the Conda environment and use [conda develop](https://docs.conda.io/projects/conda-build/en/latest/resources/commands/conda-develop.html) to add the path permanently to the PYTHONPATH of the Conda environment.

Can I use conda on Windows?

Conda is a powerful package manager and environment manager that you use with command line commands at the Anaconda Prompt for Windows, or in a terminal window for macOS or Linux.


1 Answers

putting the comments above together in a simple batch script works flawlessly:

@echo off    
set PATH=%PATH%;C:\ProgramData\Anaconda3\Scripts
%windir%\system32\cmd.exe "/K" C:\ProgramData\Anaconda3\Scripts\activate.bat <env-name>
like image 143
Jonathan Avatar answered Sep 18 '22 17:09

Jonathan