macOS pyinstaller打包python程序, subprocess无法运行

在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-statement

IMPORTANT: 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)

不知道有朋友遇见过这样的问题没? 该如何解决! 

评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

auspark

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值