简体   繁体   中英

How to get python.exe path from cmd?

I have two pythons installed to my computer. One is a separate version, another is a part of Anaconda package. I use the one which comes with Anaconda (I use Spyder to run it), because the other one doesn't have win32api and so on.

I need to find out the location of python.exe that Spyder is using when it runs the script.

My aim is to run the py script from excel VBA using the code:

Sub RunPython()

Dim objShell As Object
Dim PythonExe, PythonScript As String

Set objShell = VBA.CreateObject("Wscript.Shell")

PythonExe = """C:\Users\EEEEEEEEEEEEE\AppData\Local\Continuum\anaconda3\lib\os.py"""
PythonScript = """//fileh01/home$/EEEEEEEEEEEEE/Desktop/Python/test.py"""

objShell.Run PythonExe & PythonScript

End Sub

If I go to anaconda prompt and type python //fileh01/home$/EEEEEEEEEEEEE/Desktop/Python/test.py everything works. But when I run code from VBA, nothing happens.

In either cmd or the Anaconda prompt, You can find the location of your Python.exe using:

where python

You could also try:

where anaconda

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM