1. Weiterleitung zu NetzLiving.de
  2. Forum
    1. Unerledigte Themen
  3. zum neuen Forum
  • Anmelden
  • Suche
Dieses Thema
  • Alles
  • Dieses Thema
  • Dieses Forum
  • Seiten
  • Forum
  • Erweiterte Suche
  1. Informatik Forum
  2. Software und Anwendungen
  3. Fehler und Problemlösungen

Suche hilfe, Backend startet nicht, Fehlerbehebung

  • Dash
  • 15. Februar 2025 um 16:49
Hallo zusammen,

das Informatik-Forum geht in den Archivmodus, genaue Informationen kann man der entsprechenden Ankündigung entnehmen. Als Dankeschön für die Treue bekommt man von uns einen Gutscheincode (informatikforum30) womit man bei netzliving.de 30% auf das erste Jahr sparen kann. (Genaue Infos sind ebenfalls in der Ankündigung)

Vielen Dank für die Treue und das Verständnis!
  • Dash
    Punkte
    15
    Beiträge
    2
    • 15. Februar 2025 um 16:49
    • #1

    Ich programmiere gerade eine Anwendung. Ich muss sagen, dass ich mehr oder weniger ein totaler Anfänger bin. Aber ich will es trotzdem machen.

    Seit einer Woche hänge ich mit dem Backend fest (ich habe das Frontend und es scheint zu funktionieren) das backend will einfach nicht starten. ich habe die AI gefragt, hier im Forum nach Lösungen gesucht... nichts hat wirklich geholfen. Ich habe etwas gefunden, aber anscheinend ist die Lösung nicht optimal. utf-8 = ISO-8859-1, weil das Problem einfach ignoriert wird, aber nicht gelöst.

    Kann mir jemand helfen?

    Dies wird in der Eingabeaufforderung angezeigt:

    C:\Users\train\Desktop\App\backend>python app.py Traceback (most recent call last): File "C:\Users\train\Desktop\App\backend\app.py", line 433, in <module> db.create_all() # Create database tables ^^^^^^^^^^^^^^^ File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask_sqlalchemy\extension.py", line 900, in create_all self._call_for_binds(bind_key, "create_all") File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask_sqlalchemy\extension.py", line 881, in _call_for_binds getattr(metadata, op_name)(bind=engine) File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\sql\schema.py", line 5868, in create_all bind._run_ddl_visitor( File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 3252, in _run_ddl_visitor with self.begin() as conn: ^^^^^^^^^^^^ File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\contextlib.py", line 137, in enter return next(self.gen) ^^^^^^^^^^^^^^ File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 3242, in begin with self.connect() as conn: ^^^^^^^^^^^^^^ File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 3278, in connect return self._connection_cls(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 146, in init self._dbapi_connection = engine.raw_connection() ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 3302, in raw_connection return self.pool.connect() ^^^^^^^^^^^^^^^^^^^ File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py", line 445, in connect return _ConnectionFairy._checkout(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py", line 1259, in _checkout fairy = _ConnectionRecord.checkout(pool) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py", line 708, in checkout rec = pool._do_get() ^^^^^^^^^^^^^^ File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py", line 179, in _do_get with util.safe_reraise(): ^^^^^^^^^^^^^^^^^^^ File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py", line 146, in exit raise exc_value.with_traceback(exc_tb) File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py", line 177, in _do_get return self._create_connection() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py", line 386, in _create_connection return _ConnectionRecord(self) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py", line 670, in init self.__connect() File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py", line 896, in __connect with util.safe_reraise(): ^^^^^^^^^^^^^^^^^^^ File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py", line 146, in exit raise exc_value.with_traceback(exc_tb) File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py", line 892, in __connect self.dbapi_connection = connection = pool.invoke_creator(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\create.py", line 643, in connect return dialect.connect(*cargs, **cparams) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py", line 621, in connect return self.loaded_dbapi.connect(*cargs, **cparams) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\psycopg2_init.py", line 122, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 97: invalid start byte


    ich habe die KI gefragt, nach Lösungen hier im Forum gesucht. utf-8 = ISO-8859-1, Flask, psycopg2-binary, python, postgresql-17.2-3 aktualisiert, die uri geändert und es codiert.

  • Syntafin
    Punkte
    7.925
    Beiträge
    1.439
    • 15. Februar 2025 um 17:06
    • #2
    Code
    C:\Users\train\Desktop\App\backend>python app.py
    
    Traceback (most recent call last):
      File "C:\Users\train\Desktop\App\backend\app.py", line 433, in <module>
        db.create_all()  # Create database tables
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask_sqlalchemy\extension.py", line 900, in create_all
        self._call_for_binds(bind_key, "create_all")
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\flask_sqlalchemy\extension.py", line 881, in _call_for_binds
        getattr(metadata, op_name)(bind=engine)
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\sql\schema.py", line 5868, in create_all
        bind._run_ddl_visitor(
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 3252, in _run_ddl_visitor
        with self.begin() as conn:
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\contextlib.py", line 137, in __enter__
        return next(self.gen)
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 3242, in begin
        with self.connect() as conn:
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 3278, in connect
        return self._connection_cls(self)
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 146, in __init__
        self._dbapi_connection = engine.raw_connection()
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 3302, in raw_connection
        return self.pool.connect()
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py", line 445, in connect
        return _ConnectionFairy._checkout(self)
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py", line 1259, in _checkout
        fairy = _ConnectionRecord.checkout(pool)
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py", line 708, in checkout
        rec = pool._do_get()
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py", line 179, in _do_get
        with util.safe_reraise():
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py", line 146, in __exit__
        raise exc_value.with_traceback(exc_tb)
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py", line 177, in _do_get
        return self._create_connection()
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py", line 386, in _create_connection
        return _ConnectionRecord(self)
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py", line 670, in __init__
        self.__connect()
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py", line 896, in __connect
        with util.safe_reraise():
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py", line 146, in __exit__
        raise exc_value.with_traceback(exc_tb)
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py", line 892, in __connect
        self.dbapi_connection = connection = pool._invoke_creator(self)
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\create.py", line 643, in connect
        return dialect.connect(*cargs, **cparams)
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py", line 621, in connect
        return self.loaded_dbapi.connect(*cargs, **cparams)
      File "C:\Users\train\AppData\Local\Programs\Python\Python312\Lib\site-packages\psycopg2\__init__.py", line 122, in connect
        conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
    
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 97: invalid start byte
    Alles anzeigen

    Was ist denn auf Position 97? Geht ja scheinbar um irgendwas mit Datenbanken, so viel kann man rauslesen.

  • Dash
    Punkte
    15
    Beiträge
    2
    • 15. Februar 2025 um 17:21
    • #3

    Danke für deine Antwort.
    Auf der Line 97 von backend/app.py, Ist der Code:

    Code
    97|                 'kty': key['kty'],


    Ja, ich wollte PostSQL 17 einbinden. Das läuft.
    Ich möchte eine mobile App programmieren. Ich verwendete Python, CSS, Javascript und HTML
    Was für allfällige Informationen bräuchtest du? Den Code aus Config.json?

    from datetime import datetime, timedelta
    from flask import Flask, request, jsonify
    from flask_socketio import SocketIO, emit
    from flask_sqlalchemy import SQLAlchemy
    import threading
    import time
    import jwt
    import requests
    from functools import wraps
    import json


    Ah utf-8 = ISO-8859-1 habe ich versucht, das ist offenbar aber nicht gut, da das Problem nur ignoriert wird, aber nicht gelöst.

    Einmal editiert, zuletzt von Dash (15. Februar 2025 um 17:28)

  • PixelPatron
    Punkte
    4.131
    Beiträge
    733
    • 26. März 2025 um 20:32
    • #4

    Ich selber habe mit Python nichts am hut

    Aber chatgpt sieht das ganz klar:

    Zitat

    Der Fehler tritt auf, weil eine Datei oder ein Stream Zeichen enthält, die nicht korrekt als UTF-8 interpretiert werden können. Der Byte 0xfc entspricht „ü“ im Latin-1-Encoding, wird aber in UTF-8 nicht als gültiger Start-Byte erkannt.

    Mögliche Lösungen:

    1. Explizites Encoding angeben

    Falls du eine Datei öffnest, versuche ein anderes Encoding, z. B. latin-1 oder windows-1252:

    Code
    with open('datei.txt', 'r', encoding='latin-1') as f:
        inhalt = f.read()

    Alternativ kannst du das Encoding errors='ignore' setzen, um fehlerhafte Zeichen zu überspringen:

    Code
    with open('datei.txt', 'r', encoding='utf-8', errors='ignore') as f:
        inhalt = f.read()

    2. Datei-Encoding überprüfen

    Falls du unter Linux arbeitest, kannst du mit file oder chardet das Encoding prüfen:

    Code
    file -i datei.txt

    Oder mit Python:

    Code
    import chardet
    
    with open('datei.txt', 'rb') as f:
        result = chardet.detect(f.read())
        print(result['encoding'])

    3. Binary-Read und Umwandlung versuchen

    Falls du das Encoding nicht kennst:

    Code
    with open('datei.txt', 'rb') as f:
        inhalt = f.read().decode('utf-8', errors='replace')

    Das ersetzt ungültige Zeichen mit � statt den Fehler auszulösen.

    Lass mich wissen, falls du mehr Details brauchst!

    Alles anzeigen

Tags

  • backend
  • python
  • UnicodeDecodeError
  1. Datenschutzerklärung
  2. Impressum