localGPT icon indicating copy to clipboard operation
localGPT copied to clipboard

Backend fails with ModuleNotFoundError: No module named 'cgi'

Open sammcj opened this issue 7 months ago • 1 comments

Looks like the code might be relying on the old python CGI module which was deprecated and removed from Python 3.13 onwards.

10:10:24 [SYSTEM] INFO: ✅ rag-api started successfully (PID: 28085)
10:10:24 [SYSTEM] INFO: 🔄 Starting backend on port 8000...
10:10:24 [BACKEND] INFO: Traceback (most recent call last):
10:10:24 [BACKEND] INFO: File "/Users/samm/localGPT/backend/server.py", line 4, in <module>
10:10:24 [BACKEND] INFO: import cgi
10:10:24 [BACKEND] INFO: ModuleNotFoundError: No module named 'cgi'
10:10:26 [SYSTEM] ERROR: ❌ backend failed to start
10:10:26 [SYSTEM] INFO: 🔄 Starting frontend on port 3000...
10:10:26 [FRONTEND] INFO: > [email protected] dev
10:10:26 [FRONTEND] INFO: > next dev
10:10:29 [FRONTEND] INFO: ▲ Next.js 15.3.3
10:10:29 [FRONTEND] INFO: - Local:        http://localhost:3000
10:10:29 [FRONTEND] INFO: - Network:      http://192.168.0.223:3000
10:10:29 [FRONTEND] INFO: ✓ Starting...
10:10:30 [FRONTEND] INFO: ✓ Ready in 1334ms
10:10:31 [SYSTEM] INFO: ✅ frontend started successfully (PID: 28118)
10:10:31 [SYSTEM] ERROR: ❌ Failed to start required services: backend
10:10:31 [SYSTEM] ERROR: ❌ System startup failed
10:10:31 [SYSTEM] INFO: 🛑 Shutting down RAG system...
10:10:31 [SYSTEM] INFO: 🔄 Stopping frontend...
10:10:31 [FRONTEND] INFO:
10:10:31 [SYSTEM] INFO: ✅ frontend stopped
10:10:31 [SYSTEM] INFO: 🔄 Stopping backend...
10:10:31 [SYSTEM] INFO: ✅ backend stopped
10:10:31 [SYSTEM] INFO: 🔄 Stopping rag-api...
10:10:31 [SYSTEM] INFO: ✅ rag-api stopped
10:10:31 [SYSTEM] INFO: ✅ All services stopped

There is a temporary workaround of pip install legacy-cgi but the proper solution is probably to remove the dependency by refactoring the code that uses it.

sammcj avatar Jul 16 '25 00:07 sammcj

will have a look at it

PromtEngineer avatar Jul 18 '25 05:07 PromtEngineer