python - 有没有办法在 Windows 上使用 32 位 python 2.7 从线程打开 64 位 exe?
问题描述
我有一个在 32 位 python 2.7 中构建的 tkinter UI,我制作了一个按钮,我最终希望在不中断 UI 的情况下打开外部应用程序(64 位 exe 文件)。我的按钮启动一个线程,该线程又启动一个带有新控制台窗口的子进程并调用我的 exe 文件的完整路径。如果我将此完整路径输入到 python 脚本之外的 cmd 窗口中,我的应用程序将成功打开。
我收到错误:WindowsError: [错误 193] %1 不是有效的 Win32 应用程序
我知道这需要运行 64 位版本的 python,或者我的应用程序的 32 位版本。但是,是否有替代解决方案可以通过代码解决,而不是更改我的 python 版本或应用程序?为简单起见,我在下面包含了一些示例代码。
谢谢您的帮助!!
self.VMD_button = tk.Button(self, text="Launch VMD", command=self.show_VMD)
def show_VMD(self):
VMD_cmd = '"%s"' % "C:\VMD.exe"
thread= Thread(target=self.call_subprocess, args=[VMD_cmd])
thread.daemon = True
thread.start()
def call_subprocess(self, cmd):
proc = subprocess.Popen(cmd, creationflags=subprocess.CREATE_NEW_CONSOLE).wait()
解决方案
据我所知,答案是“不”。而且,发生的事情就是你刚刚得到的。您的应用程序是 32 位的,因此它只知道 32 位应用程序。它可能无法启动 64 位进程。相反的情况会起作用,因为存在向后(但不是向前)兼容性。
推荐阅读
- sql - 在 select 语句中使用聚合时如何分组
- git - 管理不同的数据库版本或根据git分支版本更改数据库,向后兼容
- spring-boot - 为什么 hikari 连接池在接收同时多个请求时只使用 1 或 2 个连接?
- php - 未定义索引:在第 29 行的 C:\xampp\htdocs\index.php 中提交
- swift - PDFAnnotation 单选按钮不改变背景颜色或不显示值
- jmeter - 在 JMeter 中同步来自不同线程组的线程
- maven - 如何使用 cucumber jvm 4.4.0 在没有 com.github.temyers 的情况下在功能或场景级别并行运行 Cucumber 测试?
- c++ - 错误:数字常量之前的预期非限定 ID:std::array 和 std::vector 大小分配
- clips - 如何进一步检查仅选定事实的事实值?
- python - 为什么在 PYTHON 的 SQL 查询中删除不会提交数据库中的更改?