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:

1

Create a new text file in your project directory.

2

Name it exactly requirements.txt.


📝 Structure of requirements.txt

Your file should follow these patterns:

  • Basic Package (Latest Version)

    discord.py
  • Version-Specific Package

    discord.py==2.0.0
  • Version Range

    discord.py>=2.0.0
  • GitHub 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

1

Install packages using pip.

pip install package-name
2

Update your requirements file.

pip freeze --user > requirements.txt

⚠️ 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