requirements.txt
Learn how to generate and configure the requirements.txt file to define essential dependencies for hosting your Python project on Discloud.
ποΈ What is requirements.txt?
requirements.txt?The requirements.txt file is essential for Python projects. It lists all dependencies and their versions, ensuring consistent package installation during deployment on Discloud.
π οΈ How to Create requirements.txt
requirements.txtYou can create this file using two methods:
Create a new text file in your project directory.
Name it exactly requirements.txt.
Ensure Python and pip are installed (installation guide).
Open your terminal in the project directory and run.
pip freeze --user > requirements.txtThis automatically generates a list of all installed packages with their exact versions.
π Structure of requirements.txt
requirements.txt Your file should follow these patterns:
Basic Package (Latest Version)
discord.pyVersion-Specific Package
discord.py==2.0.0Version Range
discord.py>=2.0.0GitHub Repository (Unstable Version)
git+https://github.com/Rapptz/discord.py
Best Practices
π Lock critical dependencies with
==for specific versionsπ Use
>=for packages expecting updatesπ» Always test with exact versions before deployment
π¦ Adding Packages
Install packages using pip.
Update your requirements file.
β οΈ Important Notes
Only include packages you actively installed via pip β imported modules don't automatically equal required packages!
For GitHub-based packages, include the full repository URL as shown in the examples.
If encountering installation issues, verify all package versions are compatible with your Python version.
Last updated