a month ago
Issue: FastAPI Deployment Fails with ModuleNotFoundError: No module named 'jose'
Context
I’m deploying a FastAPI backend (Python 3.12) on Railway using a split architecture:
API service →
requirements.txtWorker service →
requirements-worker.txtProcfile:
web: uvicorn backend.main:app --host 0.0.0.0 --port $PORT
The app works locally without issues, but fails after deployment.
Error Observed
From Railway logs:
ModuleNotFoundError: No module named 'jose'
👉
Stack trace shows failure during import:
from backend.app.core.jwt import create_access_token, decode_token
from jose import jwt, JWTError
📦 Dependencies (Relevant Section)
requirements.txt includes:
fastapi==0.115.0
uvicorn[standard]==0.30.0
pydantic[email]==2.6.1
sqlalchemy==2.0.25
psycopg2-binary==2.9.9
asyncpg==0.29.0
python-jose[cryptography]==3.3.0 ← INCLUDED
passlib[bcrypt]==1.7.4
argon2-cffi==23.1.0
So the missing module should be installed.
What I Already Verified
App imports successfully locally
python-jose[cryptography]is present inrequirements.txt
No duplicate or conflicting dependency entries
No lazy import issues (JWT is required at startup)
Worker-related dependencies separated correctly
API does NOT import Celery / Redis at startup
Observed Behavior
Railway deploy succeeds
Container starts
Immediately crashes on startup due to missing
joseLogs repeatedly show same import failure loop
Suspected Cause
This looks like a build cache issue, where:
Railway is not reinstalling dependencies
Cached layer is reused
python-josenever gets installed in runtime environment
Questions
Does Railway sometimes skip dependency installation due to caching, even when
requirements.txtchanges?What is the recommended way to force a clean rebuild?
Is there a known issue with:
Python 3.12 + Nixpacks
Optional dependency syntax like
python-jose[cryptography]?
Should I:
Clear build cache manually?
Delete & recreate the service?
Use a custom build command?
Temporary Workarounds Tried
Added new lines to
requirements.txtto force rebuildRe-deployed multiple times
Verified Procfile and entrypoint
Still facing the same issue.
Expected Behavior
App should start successfully and expose:
/docs (Swagger UI)
/openapi.json
🙏 Help Needed
Looking for guidance on:
Forcing dependency reinstall on Railway
Diagnosing build cache issues
Any known compatibility issues with
python-jose
2 Replies
Status changed to Awaiting Railway Response Railway • about 1 month ago
a month ago
This is clearly an application-level issue (Python dependency/configuration problem) it's likely not the correct
requirements.txtStatus changed to Awaiting User Response Railway • about 1 month ago
angelo-railway
This is clearly an application-level issue (Python dependency/configuration problem) it's likely not the correctrequirements.txt
a month ago
requirements.txtfastapi==0.115.0
uvicorn[standard]==0.30.0
pydantic[email]==2.6.1
python-dotenv==1.0.1
python-multipart==0.0.9
sqlalchemy==2.0.25
alembic==1.13.1
psycopg2-binary==2.9.9
asyncpg==0.29.0
databases==0.9.0
python-jose[cryptography]==3.3.0
passlib[bcrypt]==1.7.4
argon2-cffi==23.1.0
pandas==2.2.2
openpyxl==3.1.5
PyMuPDF==1.24.9
boto3==1.34.162
openai==1.40.6
tenacity==8.5.0
# force-rebuild-3
Status changed to Awaiting Railway Response Railway • about 1 month ago
Status changed to Open Railway • about 1 month ago
Status changed to Solved loveleetsaini • about 1 month ago