【问题标题】:How to fix Pyinstaller Mac Os error when creating onefile app创建 onefile 应用程序时如何修复 Pyinstaller Mac Os 错误
【发布时间】:2019-02-24 04:59:36
【问题描述】:

您好,我正在尝试在 Mac OS 10.13 中使用 pyinstaller 但我收到了那个错误:

teloss-Mac:client telos$ pyinstaller --onefile gui.py 
94 INFO: PyInstaller: 3.4
94 INFO: Python: 2.7.15
114 INFO: Platform: Darwin-17.7.0-x86_64-i386-64bit
116 INFO: wrote /Users/telos/Desktop/Telos-Monitor-Tool/client/gui.spec
134 INFO: UPX is not available.
137 INFO: Extending PYTHONPATH with paths
['/Users/telos/Desktop/Telos-Monitor-Tool/client',
 '/Users/telos/Desktop/Telos-Monitor-Tool/client']
137 INFO: checking Analysis
138 INFO: Building Analysis because Analysis-00.toc is non existent
138 INFO: Initializing module dependency graph...
141 INFO: Initializing module graph hooks...
258 INFO: running Analysis Analysis-00.toc
273 INFO: Caching module hooks...
280 INFO: Analyzing /Users/telos/Desktop/Telos-Monitor-Tool/client/gui.py

Syntax error in /Users/telos/Desktop/Telos-Monitor-Tool/client/gui.py
  File "/Users/telos/Desktop/Telos-Monitor-Tool/client/gui.py", line 98
     msg.exec()
            ^
 SyntaxError: invalid syntax

最奇怪的是,在 linux 和 windows 上,脚本运行良好,并且 gui.py 中没有语法错误

如果在 Mac Os 中我使用 python gui.py 脚本工作正常,但如果使用 python 启动器会收到相同的错误 发送错误的部分代码:

    @staticmethod
    def _donation_messages(self):
        msg = QMessageBox()
        msg.setIcon(QMessageBox.Information)
        msg.setWindowTitle("")
        msg.setWindowIcon(QIcon('img\icon.ico'))
        msg.setText("")
        msg.setTextInteractionFlags(Qt.TextSelectableByKeyboard|Qt.TextSelectableByMouse)
        msg.exec()

谢谢帮助

【问题讨论】:

  • msg.exec()更改为msg.exec_()
  • 谢谢。你能解释一下为什么我使用os.getcwd,然后在编译后使用join config到这个路径,在Linux和Windows中都可以。在 Mac OS 中,os.getcwd 没有正确的路径?谢谢

标签: python-3.x macos pyqt5 pyinstaller


【解决方案1】:

添加@eyllanesc 写帮助很好,谢谢需要将msg.exec() 更改为msg.exec_()

【讨论】:

    猜你喜欢
    • 2012-01-22
    • 2011-07-12
    • 2011-11-07
    • 2021-06-27
    • 1970-01-01
    • 1970-01-01
    • 2018-08-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多