Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make batch files run in anaconda prompt

After installing anaconda3 in windows, I can run python commands from the anaconda prompt, but not from the windows command prompt. I would like to make a desktop shortcut to activate my environment and run spyder from it. Previously, I would do this with a .bat file, but now that I cannot run python commands from cmd.exe this doesn't work.

Is there an alternative way of running batch files for the anaconda prompt? I know that I could just modify my PATH to get cmd.exe to run python commands, but I'd like to avoid this if possible.

like image 736
SuperNano Avatar asked Sep 19 '17 16:09

SuperNano


People also ask

How do I run a batch file from command prompt?

Open Start. Search for Command Prompt, right-click the top result, and select the Run as administrator option. Type the following command to run a Windows 10 batch file and press Enter: C:\PATH\TO\FOLDER\BATCH-NAME. bat.

How do I run a program in Anaconda prompt?

Click Start�All Programs�Anaconda (64-bit)�Anaconda Command Prompt. � A command prompt window will open. Type idle to run the Python interpreter. A new window titled Python Shell will open and you will see the Python >>> command prompt.

How do I make a batch file executable?

Create Batch File to Run EXE Invalid switch: If you set some parameters without specifying the "WindowName" or at least the empty quotation marks "" , you will get the “Invalid switch” error. Save your file with the file extension . bat , e.g. run-exe-program. bat and double click on it to run the .exe program.


1 Answers

I believe all the Anaconda prompt does is open CMD and run a batch file. Make the first command of your script:

call <anaconda_dir>/Scripts/activate.bat <anaconda_dir> 
like image 72
Jeremy McGibbon Avatar answered Sep 21 '22 17:09

Jeremy McGibbon