0

我在 python 2 中的 Qgis2.18 上开发了一个插件(在 linux 环境中工作),我今天正在尝试将我的代码转换为 python3,以便我可以在 Qgis3.18 上直接在 Windows 环境中使用它。

我的插件检索用户填写的文本信息,并使用 subprocess.popen 函数执行 .exe,这就是我卡住的地方

import subprocess

proc = subprocess.Popen(['Traitement_2.exe', r"cd C:/Users/Utilisateur/Traitement"],stdout=subprocess.PIPE, stderr=subprocess.PIPE,encoding = "ISO-8859-1", shell =True, text=True) print(proc.stdout) while True: Lecture = proc.stdout.readline()

print (lecture)
if 'FIN' in lecture:
    print('Le Traitement est fini')
    break

如果我在 Windows 命令提示符下运行这个 python 代码(通过执行 py test_py2.py),我的程序 Traitement_2.exe 运行并返回控制台中显示的字符串(并且只有字符串),如下所示:output image of my script test_py2.py

但是当我把这段代码放在我的 plugin.py(Qgis 插件)中时,什么也没有开始。我也没有收到错误,我只是觉得什么都没有发生。读取变量是类型但为空。

您有解决方案或需要考虑的事情吗?

提前致谢

4

0 回答 0