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?
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
You 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
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