Adding GitHub repository dependencies to requirements.txt file

I need help with adding a package from GitHub to my requirements.txt file. I can install the package directly using this command:

pip install git+https://github.com/company/awesome-library.git

This works perfectly when I run it manually. But now I want to include this same dependency in my requirements.txt so other developers can install it automatically.

I tried adding these lines to my requirements.txt:

-f git+https://github.com/company/awesome-library.git
awesome-library==1.2.dev

But when I run pip install -r requirements.txt, I get this error:

Downloading/unpacking awesome-library==1.2.dev (from -r requirements.txt (line 15))
  Could not find a version that satisfies the requirement awesome-library==1.2.dev
No distributions matching the version for awesome-library==1.2.dev

What is the correct way to specify a GitHub repository as a dependency in requirements.txt? I looked through the pip documentation but could not find clear examples for this specific use case.

You should simplify the way you specify the GitHub repository in your requirements.txt. Instead of using the -f flag, directly include the repository URL. For example, use git+https://github.com/company/awesome-library.git. If you require a specific tag or branch, append it as such: git+https://github.com/company/[email protected] or git+https://github.com/company/awesome-library.git@main. This method allows pip to clone and install the package without needing to specify versions like traditional packages on PyPI. Ensure that everyone on your team has access to the repository, particularly if it is private.

skip the -f flag - it won’t work here. just add git+https://github.com/company/awesome-library.git straight to ur requirements.txt and drop the version line. need a specific commit? use git+https://github.com/company/awesome-library.git@commit-hash