Deployment Issue: ModuleNotFoundError for Flask with Poetry-based Project

Hello, I'm having trouble deploying a Flask app on Railway using Poetry for dependency management. Despite having Flask listed in my pyproject.toml file, the deployment logs keep showing a ModuleNotFoundError for Flask. I've verified that Flask is correctly specified in my pyproject.toml. Has anyone encountered this issue when deploying with Poetry on Railway? Any guidance would be much appreciated. Thank you!
10 Replies
Percy
Percy15mo ago
Project ID: 1fdaefcc-07e9-4a72-870a-ccc581cf5b25
caleb4536
caleb453615mo ago
1fdaefcc-07e9-4a72-870a-ccc581cf5b25
Brody
Brody15mo ago
do you happen to also have a requirements.txt file?
furi.mu
furi.mu15mo ago
Please share what you're filling out in pyproject.toml.
caleb4536
caleb453615mo ago
Hey Brody and Furimu, Thanks for getting back so quick! @Brody : Yep, was using poetry with a pyproject.toml before. Switched over to a requirements.txt now for the Railway deploy. @furimu : About the pyproject.toml - it had the usual stuff, dependencies and all. But since I'm on requirements.txt now, not sure if that matters anymore. Still, if you wanna see it, just let me know. Got the app up on Railway, but hitting an endpoint doesn’t give any response. Kinda stumped here. Here is my procfile:
web: gunicorn app:app
web: gunicorn app:app
and my app.py
from flask import Flask, jsonify
# import oss

app = Flask(__name__)

@app.route('/test', methods=['GET'])
def test():
return "Hello, World!"

if __name__ == "__main__":
app.run()
from flask import Flask, jsonify
# import oss

app = Flask(__name__)

@app.route('/test', methods=['GET'])
def test():
return "Hello, World!"

if __name__ == "__main__":
app.run()
and the command I'm using to call the server curl -X GET <url>/test Thanks a ton for the help!
Brody
Brody15mo ago
what is the url? btw, what i was getting at was that railway checks for a requirements.txt before it checks for a pyproject.toml, and will use whatever it finds first so im gussing it found the requirements.txt file and it didnt have flask in it it may be a typo, but just thought id mentioned it, you said procfile but that file requires a capital P
furi.mu
furi.mu15mo ago
If it's a Module not found error, it's not Procfile's fault. @CalebPlease share what you're filling out in requirements.txt
Brody
Brody15mo ago
would you happen to be using ai to answer these questions?
furi.mu
furi.mu15mo ago
no, sorry i use deepl
Brody
Brody15mo ago
okay then please translate and read the persons message you are replying to
Want results from more Discord servers?
Add your server