简体   繁体   English

PyInstaller:文件未找到错误

[英]PyInstaller: FIleNotFoundError

I am trying to bundle a one-file app.我正在尝试捆绑一个单文件应用程序。 When I try to execute my .exe file I get the following error:当我尝试执行我的 .exe 文件时,我收到以下错误:

Traceback (most recent call last):
  File "__main__.py", line 19, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
  File "tables\__init__.py", line 38, in <module>
  File "tables\__init__.py", line 22, in _delvewheel_init_patch_0_0_17
  File "os.py", line 1117, in add_dll_directory
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Users\\natas\\AppData\\Local\\Temp\\_MEI104162\\tables.libs'
[2216] Failed to execute script '__main__' due to unhandled exception!

If I understood correctly, after execution starts pyinstaller creates a temporary folder _MEIxxxxx and it can't find tables.libs folder which contains .dll files.如果我理解正确,pyinstaller 在执行开始后会创建一个临时文件夹 _MEIxxxxx 并且它找不到包含 .dll 文件的 tables.libs 文件夹。

  • I tried to include this folder to pathex.我试图将此文件夹包含在 pathex 中。 It didn't work.它没有用。
pathex = ['C:\\Users\\natas\\Documents\\SINDEL\\MDM_ver1\\mdm_ver1', 'C:\\Users\\natas\\Documents\\SINDEL\\MDM_ver1\\.venv\\Lib\\site-packages\\tables.libs']
  • Then I added every .dll file from the folder:然后我添加了文件夹中的每个 .dll 文件:
p = r'C:\Users\natas\Documents\SINDEL\MDM_ver1\.venv\Lib\site-packages\tables.libs'
added_binaries = [
    (os.path.join(p, 'blosc-965398da.dll'), '.'),
    (os.path.join(p, 'hdf5-a241c97c.dll'), '.'),
    (os.path.join(p, 'libbz2-e4ba6a29.dll'), '.'),
    (os.path.join(p, 'zlib-e2d94386.dll'), '.'),
    (os.path.join(p, 'zstd-34920894.dll'), '.')
]
a = Analysis(
    ['__main__.py'],
    pathex=['C:\\Users\\natas\\Documents\\SINDEL\\MDM_ver1\\mdm_ver1'],
    binaries=added_binaries,
    datas=[],
    hiddenimports=[],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=block_cipher,
    noarchive=False,
)

But it didn't work too.但它也没有奏效。

  • Only when I created a one-folder program and manually added 'tables.libs' to program directory it worked.只有当我创建了一个单文件夹程序并手动将“tables.libs”添加到程序目录时它才起作用。

So my question is how can I include 'tables.libs' to my one-file .exe?所以我的问题是如何将“tables.libs”包含到我的单一文件 .exe 中?

My .spec file:我的 .spec 文件:

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

import os

block_cipher = None

a = Analysis(
    ['__main__.py'],
    pathex=['C:\\Users\\natas\\Documents\\SINDEL\\MDM_ver1\\mdm_ver1'],
    binaries=[],
    datas=[],
    hiddenimports=[],
    hookspath=[],
    hooksconfig={},
    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,
    a.binaries,
    a.zipfiles,
    a.datas,
    [],
    name='__main__',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)

I use python 3.10, pyinstaller 5.1我使用 python 3.10,pyinstaller 5.1

我只需要将所有 .dll 文件添加到数据中的 tables.libs 中:

datas=[(r'C:\Users\natas\Documents\SINDEL\MDM_ver1\.venv\Lib\site-packages\tables.libs\*.dll', 'tables.libs')],

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PyInstaller - FileNotFoundError:没有这样的文件或目录:&#39;&#39; - PyInstaller - FileNotFoundError: No such file or directory: '' PyInstaller Executable FileNotFoundError (Errno 2) - PyInstaller Executable FileNotFoundError (Errno 2) PyInstaller FileNotFoundError “scipy.libs” - PyInstaller FileNotFoundError "scipy.libs" PyInstaller - FileNotFoundError: [Errno 2] 没有这样的文件或目录 - PyInstaller - FileNotFoundError: [Errno 2] No such file or directory PyInstaller 包导致 FileNotFoundError 与多处理生成方法 - PyInstaller bundle causes FileNotFoundError with multiprocessing spawn method PyInstaller + UI 文件 - FileNotFoundError: [Errno 2] 没有这样的文件或目录: - PyInstaller + UI Files - FileNotFoundError: [Errno 2] No such file or directory: 运行pyinstaller可执行文件时出现FileNotFoundError [Errno 2]? - FileNotFoundError [Errno 2] when running pyinstaller executable? Pyinstaller &amp; Matplotlib。 如何解决: FileNotFoundError: [Errno 2] No such file or directory:..? - Pyinstaller & Matplotlib. How to solve: FileNotFoundError: [Errno 2] No such file or directory:..? PyInstaller filenotfounderror 并且仅在作为 systemd 服务运行时无法导入名称 - PyInstaller filenotfounderror and cannot import name only when run as systemd service PyInstaller 错误:FileNotFoundError:[Errno 2] 没有这样的文件 ot 目录:'myKivyfile.kv' - PyInstaller Error: FileNotFoundError: [Errno 2] No such file ot directory: 'myKivyfile.kv'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM