ModulenotFoundError: Kein Modul mit dem Namen 'app.routes.Sst' im Docker -Container mit ChatbotPython

Python-Programme
Anonymous
 ModulenotFoundError: Kein Modul mit dem Namen 'app.routes.Sst' im Docker -Container mit Chatbot

Post by Anonymous »

Ich denke, ich habe verschiedene Lösungen ausprobiert, ich habe viele Stunden damit verbracht, bevor ich diesen Beitrag gesendet habe, aber ich kann MySlef immer noch nicht bewältigen. Ich leite Docker -Container mit Rag Chatbot aus. Sie werden auch feststellen, dass ich den App -Ordner nicht von meinem Localhost in ein Bild kopiere, da ich Volumes an die Anwendung, DB und Dokumente montiere. Könntest du mir helfen, das Problem zu lösen? Hier ist die Dockerfile: < /p>

Code: Select all

# Use a lightweight Python base image with necessary dependencies
FROM python:3.10-slim

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app

# Install necessary system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
libgl1-mesa-glx \
libglib2.0-0 \
libpoppler-cpp-dev \
tesseract-ocr \
portaudio19-dev \
git \
ffmpeg \
mpg321 \
&& rm -rf /var/lib/apt/lists/*

# Set the working directory in the container
WORKDIR /app

# Copy the requirements.txt into the container
COPY requirements.txt /app/

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Expose API port (FastAPI will run on port 8000)
EXPOSE 8000

# Copy the application files into the container
#COPY .  /app

# Start the bash shell and keep the container running
CMD ["bash", "-c", "while true; do sleep 1000;  done"]
Ich führe diesen Container mit diesem Befehl aus:

Code: Select all

~/projekty/chatbot1$ docker run -p 8000:8000 --name chatbot   -v /home/myuser/projekty/chatbot1/vector_db:/app/vector_db   -v /home/myuser/projekty/chatbot1/documents:/app/documents   -v /home/myuser/projekty/chatbot1/rag-chatbot:/app   -e OPENAI_API_KEY=your-api-key-here   rag-chatbot
Innerhalb des Containers Wenn ich Baum ausführe, bekomme ich:

Code: Select all

/app
root@319388c4b543:/app# tree
.
├── Dockerfile
├── Dockerfile (copy)
├── __init__.py
├── app
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-310.pyc
│   │   ├── chatbot.cpython-310.pyc
│   │   ├── main.cpython-310.pyc
│   │   └── tts.cpython-310.pyc
│   ├── chatbot.py
│   ├── documents
│   ├── images
│   ├── llm
│   │   └── anwser_generation.py
│   ├── main.py
│   ├── parsers
│   │   ├── __init__.py
│   │   ├── excel_parser.py
│   │   ├── pdf_parser.py
│   │   └── word_parser.py
│   ├── routes
│   │   ├── __init__.py
│   │   ├── __pycache__
│   │   │   ├── __init__.cpython-310.pyc
│   │   │   ├── voice_mode.cpython-310.pyc
│   │   │   └── written_mode.cpython-310.pyc
│   │   ├── stt.py
│   │   ├── tts.py
│   │   ├── voice_mode.py
│   │   └── written_mode.py
│   ├── static
│   │   └── index.html
│   ├── stt.py
│   ├── tts.py
│   └── vector_db
├── documents
│   └── Tabb'sTROY-Final.pdf
├── requirements.txt
└── vector_db
├── index
│   ├── =1.10.0,
│   ├── =1.21.0
│   ├── =3.7.0,
│   ├── =4.20.0,
│   ├── index.faiss
│   ├── index.faiss2
│   ├── index.pkl
│   └── metadata.json
└── vector_db
└── index
├── index.faiss
├── index.faiss2
├── index.pkl
└── metadata.json

16 directories, 40 files
< /code>
Ich führe meine Anwendung im Container mit diesem Befehl aus:  < /p>
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
Und ich erhalte

Code: Select all

Traceback (most recent call last):
File "/usr/local/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/usr/local/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.10/site-packages/uvicorn/_subprocess.py", line 76, in subprocess_started
target(sockets=sockets)
File "/usr/local/lib/python3.10/site-packages/uvicorn/server.py", line 61, in run
return asyncio.run(self.serve(sockets=sockets))
File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "uvloop/loop.pyx", line 1518, in uvloop.loop.Loop.run_until_complete
File "/usr/local/lib/python3.10/site-packages/uvicorn/server.py", line 68, in serve
config.load()
File "/usr/local/lib/python3.10/site-packages/uvicorn/config.py", line 473, in load
self.loaded_app = import_from_string(self.app)
File "/usr/local/lib/python3.10/site-packages/uvicorn/importer.py", line 24, in import_from_string
raise exc from None
File "/usr/local/lib/python3.10/site-packages/uvicorn/importer.py", line 21, in import_from_string
module = importlib.import_module(module_str)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 992, in _find_and_load_unlocked
File "", line 241, in _call_with_frames_removed
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "/app/app/__init__.py", line 4, in 
from app.main import app
File "/app/app/main.py", line 4, in 
from app.routes.voice_mode import router as voice_router
File "/app/app/routes/voice_mode.py", line 3, in 
from .sst import speech_to_text
ModuleNotFoundError: No module named 'app.routes.sst'
Die Datei der /app/app/routes/voice_mode.py ist diese:

Code: Select all

from fastapi import APIRouter
#from app.sst import speech_to_text - FAILS
#from ..sst import speech_to_text - FAILS
from .sst import speech_to_text
from .tts import text_to_speech
import openai
(ruhen Sie nicht relevant, es fällt in Zeile 4) aus .Sst importieren rede_to_text

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post