> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dscloud.pt/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Create Your requirements.txt File

> Learn how to create a requirements.txt file for Python projects

# Creating Your `requirements.txt` File

The `requirements.txt` file is a standard way to define dependencies for your Python project. It ensures consistency across development environments by listing all external packages your project relies on. Follow these steps to create and manage it effectively.

## Step 1: Activate a Virtual Environment (Recommended)

Using a virtual environment helps isolate your project dependencies, preventing conflicts with global packages.

### Activating a Virtual Environment

* **Windows**:
  ```bash theme={null}
  python -m venv venv
  .\venv\Scripts\activate
  ```

* **Linux/macOS**:
  ```bash theme={null}
  python3 -m venv venv
  source venv/bin/activate
  ```

## Step 2: List Dependencies

You can manually list your required packages in `requirements.txt`, but the easiest way is to generate it using `pip freeze`.

### Automatically Generate `requirements.txt`

Once you've installed your dependencies inside the virtual environment, run:

```bash theme={null}
pip freeze > requirements.txt
```

This will create a `requirements.txt` file with all installed packages and their versions.

### Best Practices

> **Warning:** Only include necessary dependencies (e.g., `discord.py`) to avoid unnecessary bloat in production.

### Example `requirements.txt` File

```plaintext theme={null}
flask
requests
discord.py
```

## Step 3: Review and Edit

Open `requirements.txt` in a text editor and remove any unnecessary dependencies to keep your project clean.

## Step 4: Use and Share

Distribute `requirements.txt` to collaborators or use it to set up your project on another system.

### Install Dependencies from `requirements.txt`

To recreate the environment on a new machine, run:

```bash theme={null}
pip install -r requirements.txt
```

## Bonus Tips

* **Regular Updates:** Update `requirements.txt` whenever dependencies change.
* **Avoid Global Environments:** Always run `pip freeze` inside a virtual environment to avoid including unrelated packages.
* **Compatibility with DS Cloud:** If using `pyproject.toml` or `Pipfile`, generate a `requirements.txt` for compatibility.

A well-maintained `requirements.txt` file ensures a smooth development and deployment experience.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.