//////////// Requirements
-
Initial Setup: After creating a virtual environment for your project, generate the
requirements.txt
file with the command:pip freeze > requirements.txt
This captures the current state of dependencies installed in your virtual environment.
-
Dependency Changes: Whenever you add a new dependency to your project or update an existing one, you should update the
requirements.txt
file to reflect these changes. You can do this by running the same command:pip freeze > requirements.txt
This ensures that the
requirements.txt
file is up-to-date with the latest dependencies. -
Sharing with Others: When you share your project with others (e.g., by pushing changes to a Git repository), include the
requirements.txt
file. This allows others to recreate the same environment with the necessary dependencies. -
Dependency Management: When others clone your repository and set up the project, they can install the dependencies listed in the
requirements.txt
file using the command:pip install -r requirements.txt
This command installs all the dependencies listed in the file, ensuring that they have the same environment as you.
By following this workflow, you keep the requirements.txt
file updated with the current state of your project's dependencies, making it easier for others to collaborate on your project or set up the environment on their own machines.