我正在尝试调用pyuic5
以subprocess.Popen
将 qt5 .ui 文件从 Windows 上的 python 脚本中转换为 python。
command = "pyuic5 -x " + filein + " -o " + fileout
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=None, shell=False, cwd=folderPath)
output = process.communicate()
给我以下错误:
Traceback (most recent call last):
File "N:\My Documents\Code\Python Projects\Work projects\PyQtConverter\src\fonctions.py", line 36, in convert_qt_2_py
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=None, shell=False, cwd=folderPath)
File "C:\Python35\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:\Python35\lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] Le fichier spécifié est introuvable
似乎问题来自调用pyuic5
(尽管它被认为是 windows cmd 的有效命令?)。设置shell=True
解决了问题,但我一直在阅读此选项可能存在安全风险,不推荐使用。我应该以不同的方式做事吗?