[英]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 文件夹。
pathex = ['C:\\Users\\natas\\Documents\\SINDEL\\MDM_ver1\\mdm_ver1', 'C:\\Users\\natas\\Documents\\SINDEL\\MDM_ver1\\.venv\\Lib\\site-packages\\tables.libs']
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.但它也没有奏效。
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.