在macos上使用pyinstaller打包python生成app, app也能启动运行, 可是在python中有用到pyside2的QThread和subprocess
经过验证, subprocess不能启动运行, 走到这里就停住了,
可是在pycharm中调试时可以运行的, 打包成命令行模式也是可以运行的, 不知道为何在app中却会卡在subprocess这里
class subprocessExeCommand(QThread):
stmclient='shell_cmd'
sigResult=Signal(list)
def __init__(self,port,br,fm,addr):
super(stmcli, self).__init__()
self.usbport = port
self.br= br
self.fm= fm
self.isBin=self.fm.endswith('.bin')
self.bPercent=False
self.addr=addr
self.shellcmd=self.cmd()
def cmd(self):
if not self.isBin:
return '{} -c port={} br={} -d {}'.format(self.stmclient,self.usbport,self.br,self.fm)
else:
return '{} -c port={} br={} -d {} {}'.format(self.stmclient,self.usbport,self.br,self.fm,self.addr)
def run(self):
cmd = shlex.split(self.shellcmd)
p = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
strbuf = ''
pb = precentbuf()
bPostInfo=False
while p.poll() is None:
line = p.stdout.read(1)
line = line.decode('utf8')
strbuf += line
if p.returncode == 0:
print('Subprogram success')
else:
print('Subprogram failed')
warn-main.txt中提示信息如下:
This file lists modules PyInstaller was not able to find. This does not
necessarily mean this module is required for running you program. Python and
Python 3rd-party packages include a lot of conditional or optional modules. For
example the module 'ntpath' only exists on Windows, whereas the module
'posixpath' only exists on Posix systems.Types if import:
* top-level: imported at the top-level - look at these first
* conditional: imported within an if-statement
* delayed: imported from within a function
* optional: imported within a try-except-statementIMPORTANT: Do NOT post this list to the issue-tracker. Use it as a basis for
yourself tracking down the missing module. Thanks!missing module named org - imported by copy (optional)
missing module named _sha512 - imported by hashlib (delayed, conditional, optional)
missing module named _sha256 - imported by hashlib (delayed, conditional, optional)
missing module named _md5 - imported by hashlib (delayed, conditional, optional)
missing module named _sha - imported by hashlib (delayed, conditional, optional)
missing module named 'org.python' - imported by pickle (optional)
missing module named msvcrt - imported by subprocess (conditional)
missing module named riscosenviron - imported by os (conditional, optional)
missing module named riscospath - imported by os (conditional)
missing module named riscos - imported by os (conditional, optional)
missing module named ce - imported by os (conditional, optional)
missing module named _emx_link - imported by os (conditional)
missing module named os2 - imported by os (conditional, optional)
missing module named nt - imported by os (conditional, optional), ntpath (optional)
missing module named _subprocess - imported by subprocess (conditional)
missing module named 'System.IO' - imported by serial.serialcli (top-level)
missing module named System - imported by serial.serialcli (top-level)
missing module named 'collections.abc' - imported by typing (optional)
不知道有朋友遇见过这样的问题没? 该如何解决!