为pyinstaller使用--onefile不会创建单个可执行文件,而是会继续创建目录

时间:2019-12-26 23:53:18

标签: python command exe pyinstaller

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

pyinstaller script.spec script.py

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

pyinstaller --onefile script.spec script.py

它创建了一个可执行文件,相反,它做的事情就像我没有包含它一样。

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

spec文件代码:

# -*- 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')

1 个答案:

答案 0 :(得分:0)

您的命令正确。

您需要做的是检查 dict 文件

如果不使用--onefile

,其中应该有很多文件

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

相关问题