1

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?

2
  • It's not obvious why running "C:\Users\Administrator\.spyder-py3\temp2.py" would return "python file not found", unless maybe the .py file association is configured in some unusual way. Commented Jan 17, 2020 at 6:28
  • You should be able to directly run a .py file from the command prompt without having to explicitly run "python.exe". If .py files are associated with the "py.exe" launcher, and "temp2.py" either has no shebang, or a "python" virtual shebang (not "python3"), such as "#!/usr/bin/python", then the launcher will run the python.exe executable from the environment that's activated by activate.bat. It can't be a "python3" shebang because, as designed, the launcher will only run a registered Python 3 for that case, not the executable from the active environment. Commented Jan 17, 2020 at 6:30

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.