Search code examples
pythonpackagerequirements.txt

Does python file with packages to install must be called requirements.txt?


I have quick question, becouse I have a weird bug. In my code I create virtual environment for python and then install all packages from file using pip install -r <file name>. When I run it locally everything is ok, when I run it remotely on machine it fails and shows that some package is not installed.

I found out, that when I call file with packages needed requirements.txt everything works fine locally and remotely, problems apprear when I change file name.

My question is then, is there any convention about naming this file? I thought this name is just a tip and a "standard", but it appears then it is more than that.


Solution

  • From Requirements files topic from python documentation you can find all explanation regarding the use of a file to install items using pip install. You can also check in the User Guide, it mainly need the right file format that can also be found in Requirements File Format.

    It’s important to be clear that pip determines package dependencies using install_requires metadata, not by discovering requirements.txt files embedded in projects.

    So it also works with:

    pip install -r my_pacakges.txt