user3570022
user3570022

Reputation: 81

run a python script on windows command promt

I want to create a short cut on my windows desktop to run Anaconda prompt and execute a python file. I have the following which opens the Conda prompt just fine:

%windir%\System32\cmd.exe "/K" C:\Users\Administrator\Anaconda3\Scripts\activate.bat C:\Users\Administrator\Anaconda3

but subsequently i want to run this python file (C:\Users\Administrator.spyder-py3\temp2.py) as well so I added "&" to it:

%\System32\cmd.exe "/K" C:\Users\Administrator\Anaconda3\Scripts\activate.bat C:\Users\Administrator\Anaconda3 & C:\Users\Administrator\.spyder-py3\temp2.py

But this is giving me an error saying "python file not found", and I know this is a correct file and path. Any idea on how to do this?

Upvotes: 1

Views: 687

Answers (1)

user3570022
user3570022

Reputation: 81

well, I figured it out. I forgot to also add "python" right before the python file so it know that it needs python driver to execute the file:

%windir%\System32\cmd.exe "/K" C:\Users\Administrator\Anaconda3\Scripts\activate.bat C:\Users\Administrator\Anaconda3 & python C:\Users\Administrator\.spyder-py3\temp2.py

Upvotes: 1

Related Questions