使用onefile for pyinstaller不会创建单个可执行文件,而是会一直创建一个目录

2024-09-29 17:13:49 发布

您现在位置:Python中文网/ 问答频道 /正文

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

pyinstaller script.spec script.py

它创建了一个与普通目录类似的目录。但是当我这么做的时候

pyinstaller --onefile script.spec script.py

它没有创建一个可执行文件,相反,它做的事情和我没有包含它一样。你知道吗

这是与我的命令行有关还是与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')

Tags: 文件代码py目录falsetruescriptblock
1条回答
网友
1楼 · 发布于 2024-09-29 17:13:49

你的命令是正确的。你知道吗

您需要做的是检查dict文件

如果你不使用一个文件,里面应该有很多文件

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

相关问题 更多 >

    热门问题