Pyinstaller:FileNotFoundError:MultiplexedPath 必须至少包含一个路径

问题描述 投票:0回答:1

在尝试将 Python IA 脚本捆绑到可执行文件中时,我遇到了 PyInstaller 问题。我不断遇到以下错误:

FileNotFoundError: MultiplexedPath must contain at least one path

这是完整的回溯:

Exception in Tkinter callback
Traceback (most recent call last):
  File "tkinter\__init__.py", line 1967, in __call__
  File "UX.py", line 99, in enter_key_event
  File "UX.py", line 44, in question
  File "UX.py", line 58, in execution_IA
  File "files\RAG_modif_pour_UX.py", line 249, in main
  File "files\RAG_modif_pour_UX.py", line 136, in add_to_chroma
  File "langchain_chroma\vectorstores.py", line 313, in __init__
  File "chromadb\__init__.py", line 334, in Client
  File "chromadb\api\client.py", line 58, in __init__
  File "chromadb\api\shared_system_client.py", line 19, in __init__
  File "chromadb\api\shared_system_client.py", line 30, in _create_system_if_not_exists
  File "chromadb\config.py", line 425, in instance
  File "chromadb\api\segment.py", line 124, in __init__
  File "chromadb\config.py", line 318, in require
  File "chromadb\config.py", line 425, in instance
  File "chromadb\db\impl\sqlite.py", line 74, in __init__
  File "importlib_resources\_common.py", line 46, in wrapper
  File "importlib_resources\_common.py", line 56, in files
  File "importlib_resources\_common.py", line 117, in from_package
  File "importlib_resources\future\adapters.py", line 65, in get_resource_reader
  File "importlib_resources\future\adapters.py", line 70, in _standard_reader
  File "importlib_resources\future\adapters.py", line 78, in _namespace_reader
  File "importlib_resources\readers.py", line 141, in __init__
  File "importlib_resources\readers.py", line 76, in __init__
FileNotFoundError: MultiplexedPath must contain at least one path

在此之前我遇到了几个 ModuleNotFound 错误,迫使我在规范文件的隐藏导入中插入很多模块

我尝试通过以下命令指定其他路径并使用隐藏导入:

pyinstaller --paths=/path/to/file  --hidden-import 
chromadb.db.impl.sqlite 
--hidden-import 
chromadb.api 
--hidden-import 
chromadb.config 
--hidden-import 
chromadb.api.client 
--hidden-import 
chromadb.migrations 
--hidden-import chromadb.migrations.embeddings_queue UX.py

我还清理了我的.spec

尽管如此,我仍然遇到同样的错误。我已验证所有必需的文件都位于指定的目录中。

有人对如何解决这个问题有任何建议吗?

谢谢您的帮助!

我的规格文件:

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


a = Analysis(
    ['UX.py'],
    pathex=['C:\\Users\\xx\\HL-Documents\\python modif\\OLLAMA rag v2'],
    binaries=[],
    datas=[],
    hiddenimports=['chromadb.db.impl.sqlite', 'chromadb.api', 'chromadb.config', 'chromadb.api.client', 'chromadb.migrations', 'chromadb.migrations.embeddings_queue', 'importlib_resources'],
    hookspath=["\hooks"],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    noarchive=False,
    optimize=0,
)
pyz = PYZ(a.pure)

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.datas,
    [],
    name='UX',
    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,
)

我的一些进口

import customtkinter as ctk
from tkinter import filedialog
import time
from time import sleep
import os
import shutil
from files import RAG_modif_pour_UX
from pydantic.deprecated import decorator
from chromadb.telemetry.product import posthog
from chromadb.api import segment
from langchain_ollama import OllamaEmbeddings
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_chroma import Chroma
from langchain_community.document_loaders import UnstructuredPDFLoader
from langchain_community.document_loaders import OnlinePDFLoader
from langchain.prompts import ChatPromptTemplate, PromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_ollama import ChatOllama
from langchain_core.runnables import RunnablePassthrough
import os
from langchain.schema.document import Document
import shutil
from chromadb.utils.embedding_functions.onnx_mini_lm_l6_v2 import ONNXMiniLM_L6_V2
import subprocess
import sys
python pyinstaller exe chromadb
1个回答
0
投票

我遇到了同样的问题并设法解决了。

我正在使用

poetry-pyinstaller-plugin
,我只是将 chromadb 放在收集部分中并完成了任务

[tool.poetry-pyinstaller-plugin.collect]
all = [..., "chromadb"]

我想如果你把

--collect-all chromadb
放入你的 pyinstaller 命令中,就会解决它。

© www.soinside.com 2019 - 2024. All rights reserved.