9 months ago
Hello Railway Support Team,
I am trying to deploy my Python Discord bot on Railway, but I keep encountering the following recurring error in the logs:
ModuleNotFoundError: No module named 'discord'
Despite multiple attempts, this issue remains unresolved.
Here are the key details of my setup and what I have tried so far:
-
My project’s main Python file is main.py, which imports the discord module.
-
I have a requirements.txt file placed correctly at the root of the repository, containing:
py-cord==2.3.2
flask
werkzeug
gunicorn(I am using py-cord instead of discord.py because I understand it is the actively maintained fork supporting import discord.)
I included a Procfile with the line:
- Locally, inside a fresh virtual environment, the bot runs perfectly when I install dependencies with this requirements.txt.
- However, in Railway deployment logs, I do not see any indication of the pip install -r requirements.txt command being run or of the dependencies being installed.
- The build logs indicate usage of Railway’s new build system (Railpack / uv), but it does not seem to install the Discord dependency, resulting in a crash with the missing module error.
- Attempts to force cache clear and redeploy did not fix the problem.
- Python version used is 3.11.13, specified either implicitly or in runtime.txt.
- This final error is blocking me from successfully running my Discord bot on Railway.
- Could you please advise why the dependencies, particularly py-cord, fail to install during build on Railway? Is there a known issue or additional build configuration needed to ensure that requirements.txt is processed correctly?
- Also, is it recommended to specify any extra build settings or to add any specific files (like pyproject.toml) for proper Python dependency management in Railway builds?
I would highly appreciate any guidance or troubleshooting steps, or if someone on the team can inspect my project’s build environment.
17 Replies
9 months ago
Discord is not being installed, you need to explicitly add discord to your requirements.txt as well
9 months ago
Please share your full build logs
Build logs:
9 months ago
You’re right that it’s not properly detecting your requirements.txt, it seems to think that your requirements are stored elsewhere. Please share the repo
9 months ago
It’s not public
9 months ago
Yes
9 months ago
your requirement.txt file needs to be called requirements.txt
9 months ago
No prob, let me know if it works
yeah it worked! but another error was waiting for me😂 .
this one:
2025-09-13T19:06:53.000000000Z [inf] Starting Container
2025-09-13T19:06:53.749112825Z [err] DEBUG:asyncio:Using selector: EpollSelector
2025-09-13T19:06:53.749117254Z [err] WARNING:discord.client:PyNaCl is not installed, voice will NOT be supported
2025-09-13T19:06:53.749122616Z [err] DEBUG:discord.client:on_ready has successfully been registered as an event
2025-09-13T19:06:53.749127632Z [err] INFO:main:Starting Flask server and Discord bot
2025-09-13T19:06:53.749133380Z [err] INFO:discord.client:logging in using static token
2025-09-13T19:06:53.749137473Z [inf] * Serving Flask app 'main'
2025-09-13T19:06:53.749141482Z [inf] * Debug mode: off
2025-09-13T19:06:53.749145804Z [err] INFO:werkzeug:[31m[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.[0m
2025-09-13T19:06:53.749151517Z [err] * Running on all addresses (0.0.0.0)
2025-09-13T19:06:53.749158010Z [err] * Running on http://127.0.0.1:5000
2025-09-13T19:06:53.749163448Z [err] * Running on http://10.250.15.251:5000
2025-09-13T19:06:53.749167540Z [err] INFO:werkzeug:[33mPress CTRL+C to quit[0m
2025-09-13T19:06:53.749172044Z [err] DEBUG:discord.http:GET https://discord.com/api/v10/users/@me with None has returned 401
2025-09-13T19:06:53.749176815Z [err] INFO:discord.client:Cleaning up tasks.
2025-09-13T19:06:53.749183562Z [err] INFO:discord.client:Closing the event loop.
2025-09-13T19:06:53.749189101Z [err] ERROR:main:Bot or server failed to start: Improper token has been passed.
9 months ago
Well that’s a clearer error, your token is incorrect/not provided
9 months ago
!s
Status changed to Solved adam • 10 months ago