【问题标题】:How to gather all the files and the folders that was generated with pyinstaller except the executable (kivy application)如何收集除可执行文件(kivy 应用程序)之外的所有使用 pyinstaller 生成的文件和文件夹
【发布时间】:2018-10-09 15:14:19
【问题描述】:

我正在构建一个 kivy 应用程序,我使用 PyInstaller 将其转换为可执行文件,它运行良好,但问题是有很多文件(.dll、.pyd...等)是用 Myapp 生成的.exe 在同一文件夹中。我想将应用程序提供给多个用户,并且我想将所有文件和文件夹放在一个文件夹中或最多 2 个文件夹中,Myapp.exe 除外。

我将它用于另一个应用程序,因为 cx_freeze 通过生成 lib 文件夹来实现。 Pyinstaller 没有生成这个文件夹,它显示与可执行文件在同一文件夹中的所有文件。

谁能帮我解决这个问题?

这是我的 .spec:

block_cipher = None

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

a = Analysis(['Myapp.py'],
             pathex=['C:\\HOMEWARE\\Anaconda3-Windows-x86_64\\\\deskapp\\Code'],
             binaries=[],
             datas=[],
             hiddenimports=['os','pandas','sys','kivy'],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)
dict_tree = Tree(get_pandas_path(), prefix='pandas', excludes=["*.pyc"])
a.datas += dict_tree

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)
dict_tree = Tree('C:\\HOMEWARE\\Anaconda3-Windows-x86_64\\deskapp\\Code\\kv Scripts', prefix='kv Scripts', excludes=["*.pyc"])
a.datas += dict_tree
dict_tree = Tree('C:\\HOMEWARE\\Anaconda3-Windows-x86_64\\deskapp\\Code\\Images_logo', prefix='Images', excludes=["*.pyc"])
a.datas += dict_tree    
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=True,
          name='My app',
          debug=False,
          strip=False,
          upx=True,
          icon = 'C:\\HOMEWARE\\Anaconda3-Windows-x86_64\\deskapp\\Code\\Images_logo\\MyIcon.ico',
          console=False )
coll = COLLECT(exe,
                Tree('C:\\HOMEWARE\\Anaconda3-Windows-x86_64\\share\\glew\\bin\\'),
                Tree('C:\\HOMEWARE\\Anaconda3-Windows-x86_64\\share\\sdl2\\bin\\'),
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               name='My app')

这就是我在 dist 文件夹中得到的(生成 exe 的地方):

这就是我想要的(或类似的东西):

当我将 cx_freezebase = 'Win32GUI' 一起使用时,我的应用程序没有出现,我只是将 cx_Freeze: Python error in main script 作为我的应用程序的标题我看不出是什么原因。

提前谢谢你

【问题讨论】:

    标签: kivy pyinstaller cx-freeze


    【解决方案1】:

    我解决了这个问题,我用base = 'Win32GUI'使用cx_freeze,问题是由于我们使用'Win32GUI'时无法在gui中显示的日志引起的。

    我尝试将它们定向到日志文件但没有成功,因此我转到 \Anaconda3-Windows-x86_64\Lib\logging 文件夹中的 __init__.py 文件并评论在第 999 行,我将其替换为 pass。如果它有效,它并不愚蠢,希望这会对某人有所帮助。如果您有其他解决方案,请告诉我。谢谢

    这是__init__py中的代码:

    图片

    【讨论】:

      猜你喜欢
      • 2016-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-20
      • 2021-09-26
      • 2016-02-29
      相关资源
      最近更新 更多