重新 build sam build --no-cached 启动本地 API: sam local start-api C:\workspace\AWS\accounting-system\layers\psycopg2\python 如果你看到的是: bash-4.2# → 这是 Amazon Linux 容器(正确) 你必须看到 bash-4.2# 才能执行 yum。 正确的データベース Host 是你的 NAS 内网 IP 地址 Host: 192.168.0.61 Port: 55432 User: postgres Password: accounting123 Database: accounting njts_acct DB_HOST=192.168.0.61 DB_PORT=55432 DB_NAME=njts_acct DB_USER=njts_app DB_PASSWORD=njts_app2025 ---------------------- バージョン確認 python --version pip --version where python where python 没有输出 这是好事,不是坏事: 说明: 没有多个 python 冲突 没有 WindowsApps / Microsoft Store 干扰 PowerShell 里 python 能正常执行,PATH 已经是正确的 👉 结论:Python 环境 = 教科书级干净 create_njts_accounting_core.bat cd C:\workspace\njts-accounting-core\backend python -m venv .venv C:\workspace\njts-accounting-core\backend\.venv\pyvenv.cfg home = C:\Users\zxh_y\AppData\Local\Programs\Python\Python312 include-system-site-packages = false version = 3.12.9 executable = C:\Users\zxh_y\AppData\Local\Programs\Python\Python312\python.exe command = C:\Users\zxh_y\AppData\Local\Programs\Python\Python312\python.exe -m venv C:\workspace\njts-accounting-core\backend\.venv cd C:\workspace\njts-accounting-core\backend .venv\Scripts\activate uvicorn app.main:app --reload --host 127.0.0.1 --port 18080 http://localhost:18080/docs backend\requirements.txt ーーーーーーーーーーーーー fastapi==0.115.6 uvicorn[standard]==0.32.1 ーーーーーーーーーーーー pip install -r requirements.txt backend\app\main.py ーーーーーーーーーー from fastapi import FastAPI app = FastAPI( title="NJTS Accounting Core API", description="日本小規模企業向け 会計システム", version="0.1.0" ) @app.get("/") def root(): return { "message": "NJTS Accounting Core API is running", "status": "ok" } pip install psycopg[binary]==3.2.3 C:\workspace\njts-accounting-core\backend uvicorn app.main:app --reload --host 127.0.0.1 --port 18080