【问题标题】:using --onefile for pyinstaller does not create a single executable, instead it keeps creating a directory对 pyinstaller 使用 --onefile 不会创建单个可执行文件,而是会不断创建目录
【发布时间】:2020-04-17 01:25:51
【问题描述】:

我有一个 python 脚本和一个 python 规范文件。规范文件包含一些代码,这些代码添加了我的脚本所需的几个目录。当我这样做时

pyinstaller script.spec script.py

它会像平常一样创建一个目录。但是当我这样做时

pyinstaller --onefile script.spec script.py

它没有创建单个可执行文件,而是执行相同的操作,就好像我没有包含它一样。

与我的命令行有关还是与规范文件有关?

规范文件代码:

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

block_cipher = None


a = Analysis(['memrise.py'],
             pathex=['C:\\Users\\blahblahpath\\memrise'],
             binaries=[],
             datas=[('C:\\Users\\blahblahpath\\memrise\\chromedriver_win32\\','.\\selenium\\webdriver\\')],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='memrise',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=True )
coll = COLLECT(exe,
               a.binaries,
               Tree('C:\\Users\\blahblahpath\\memrise\\assets', prefix='assets\\'),
               Tree('C:\\Users\\blahblahpath\\langdetect', prefix='langdetect\\'),
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               upx_exclude=[],
               name='memrise')

【问题讨论】:

    标签: python command exe pyinstaller


    【解决方案1】:

    你的命令是正确的。

    你需要做的是检查dict文件,

    如果不使用 --onefile 里面应该有很多文件

    但是如果你使用的话,里面应该只有一个 .exe 文件。

    【讨论】:

    • 好的,我的 dict 文件包含 data=[] 中的内容,它只是将一个 exe 添加到一个目录中,还包含一个 Tree() 来创建一个目录。是这两个之一的问题吗?如果你愿意,我可以添加我的代码。
    • 我用规范文件代码更新了帖子。我认为问题与我添加目录有关。有没有办法解决这个问题?
    • hmm,您可以尝试在此处寻求帮助 (pyinstaller.readthedocs.io/en/stable/whenthingsgowrong.html)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-22
    • 1970-01-01
    • 1970-01-01
    • 2017-10-09
    • 1970-01-01
    相关资源
    最近更新 更多