Jan-Hendrik Ewers Logo

Pip Install From Private GitHub Repos

February 7, 2023    python pip github ☕️ buy me a coffee


I’m currently working on a library that I’m not quite ready yet to open source. I use it for research, and as such need to be able to install it on other machines. Originally I was just cloning the repo and setting PYTHONPATH everywhere but this quickly became cumbersome. Below are the methods that I’ve discovered to install the library.

HTTPS

So you don’t want to set up SSH with a private key and all that jazz. Simply have a look at this guide to create a private access token (PAT) with read access to the private repo.

Then run the following

pip install git+https://$USERNAME:$PAT@github.com/$GH_USER/$REPO.git@$VERSION

Some other guides online either omit the $USERNAME because it’s a new requirement or it used to work, but this is the only way it works for me these days without asking for my password.

SSH

This is by far the easiest method, but it does require that SSH is linked to your github account. If SSH is correctly set up, then run the following

pip install git+ssh://[email protected]/$GH_USER/$REPO.git@$VERSION

Extra Info

  • $VERSION can be a branch or tag
  • PATs should always have the minimum permissions possible
  • Treat your PATs like a password. DO NOT SHARE