简体   繁体   English

Python:调用可执行文件失败

[英]Python: Calling executable fails

I'm trying to run any one of these in Python... 我正在尝试在Python中运行其中任何一个...

subprocess.call(r"C:\Windows\System32\fsquirt.exe", shell=True)
subprocess.call("C:\\Windows\\System32\\fsquirt.exe", shell=True)
subprocess.call(r"C:/Windows/System32/fsquirt.exe", shell=True)
subprocess.call("C:/Windows/System32/fsquirt.exe", shell=True)

They all result in... 他们都导致...

'C:/Windows/System32/fsquirt.exe' is not recognized as an internal or external command,
operable program or batch file.

If I just copy fsquirt.exe into the local directory I can call it from there, so I'm sure I must just be doing something noob-ish with how I'm using directories. 如果我只是将fsquirt.exe复制到本地目录中,则可以从该目录中调用它,因此,我确定我对目录的使用方式必须做得有些愚蠢。

How should I do this? 我应该怎么做?

The problem was that I'm using 64 bit Windows which doesn't use System32 (running from 32bit Python). 问题是我正在使用不使用System32的64位Windows(从32位Python运行)。 64 bit Windows typically uses SysWOW64 instead of System32. 64位Windows通常使用SysWOW64而不是System32。 Calling the virtual directory Sysnative instead of either of those will sort out which one needs to be called based on what you're running (for me, 32bit Python). 调用虚拟目录Sysnative而不是这两个目录中的任何一个,将根据您所运行的内容(对我而言,是32位Python)来确定需要调用哪个虚拟目录。 Fsquirt exists only in System32, not SysWOW64. Fsquirt仅存在于System32中,而不存在于SysWOW64中。 This is different to something like Notepad which exists in both. 这与两者中都存在的类似记事本的东西不同。

subprocess.call("C:/Windows/Sysnative/fsquirt.exe")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Python中确定调用可执行文件 - Determine calling executable in Python Python调用可执行程序 - Python calling an executable program 在Excel中将Python脚本作为可执行文件调用 - Calling Python script in excel as executable Python-IPython Notebook无法找到Java可执行文件 - Python - IPython Notebook fails to find the Java executable 从另一个Python进程调用OS的Python可执行文件 - Calling OS' Python Executable from another Python Process 使用pyinstaller在Linux中创建python可执行文件,无法在Windows计算机上运行 - Creating a python executable in Linux with pyinstaller, fails to run in a Windows machine python radish-bdd可执行文件导入模块失败 - Import module fails from the Python radish-bdd executable 调用带有争论的可执行文件,并在Python脚本中更有效地获取其STDOUT - Calling and executable with arguements and getting its STDOUT more efficiently in a Python Script 从IIS上运行的Python / Django Web应用程序中调用可执行文件 - Calling an executable from within Python / Django web application running on IIS 在mpi编译的fortran可执行文件上从python调用mpirun - Calling mpirun from python on mpi compiled fortran executable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM