【问题标题】:Pyinstaller on Mac: How to open app without opening terminal first?Mac上的Pyinstaller:如何在不先打开终端的情况下打开应用程序?
【发布时间】:2020-10-01 14:49:24
【问题描述】:

所以我对 Pyinstaller 还很陌生,并试图创建一个可以在任何操作系统系统上运行而无需先打开终端的应用程序。到目前为止,我已经下载了 Pyinstaller 并在终端中运行 pyinstaller --onefile mainGUI.spec 以生成 dist 和可执行文件。我的 Spec 文件如下:

# -*- mode: python ; coding: utf-8 -*-

block_cipher = None

a = Analysis(['mainGUI.pyw', 'modules/methods.py'],
             pathex=['****'],
             binaries=None,
             datas=[('private_key/private_key.pem', '.')],
             hiddenimports=['numpy', 'pytz', 'dateutil', 'PyJWT', 'httplib2', 'Pysocks', 'json', 'time', 'openpyxl'],
             hookspath=None,
             runtime_hooks=None,
             excludes=None,
             win_no_prefer_redirects=None,
             win_private_assemblies=None,
             cipher=block_cipher)

def get_pandas_path():
    import pandas
    pandas_path = pandas.__path__[0]
    return pandas_path

dict_tree = Tree(get_pandas_path(), prefix='pandas', excludes=["*.pyc"])
a.datas += dict_tree
a.binaries = filter(lambda x: 'pandas' not in x[0], a.binaries)

pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          [],
          name='mainGUI',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          upx_exclude=[],
          runtime_tmpdir=None,
          console=False )

我在生成可执行文件时尝试了 -w --noconsole 和 --windowed 标志,但都没有奏效。从我在文档中阅读的内容来看,这些似乎是要使用的标志。

提前感谢您的任何建议/帮助。

【问题讨论】:

    标签: python python-3.x macos terminal pyinstaller


    【解决方案1】:

    想通了,至少对我来说。结果发现规范文件有些奇怪。我刚刚删除了那个并再次运行命令,新创建的命令完美运行!

    希望这对某些人有所帮助。

    【讨论】:

      猜你喜欢
      • 2019-01-21
      • 2017-08-31
      • 2011-01-02
      • 1970-01-01
      • 2016-08-20
      • 2022-01-15
      • 2019-09-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多