Prepend the url prefix git+ (See VCS Support):

Use with AIpip install git+https://github.com/tangentlabs/django-oscar-paypal.git@issue/34/oscar-0.6

And specify the branch name without the leading /.

Answer from falsetru on Stack Overflow
🌐
Adam Johnson
adamj.eu › tech › 2019 › 03 › 11 › pip-install-from-a-git-repository
'pip install' From a Git Repository - Adam Johnson
$ python -m pip install 'django @ git+https://github.com/django/django@80d38de52bb2721a7b44fce4057bcff571afc23a' Collecting django@ git+https://github.com/django/django@80d38de52bb2721a7b44fce4057bcff571afc23a Cloning https://github.com/django/django (to revision 80d38de52bb2721a7b44fce4057bcff571afc23a) to /private/var/folders/20/lzgtdyzs7wj5fc_90w1h3bhc0000gn/T/pip-install-sirxc970/django_b245ad848cac4a16a8639862854e9b94 Running command git clone --filter=blob:none --quiet https://github.com/django/django /private/var/folders/20/lzgtdyzs7wj5fc_90w1h3bhc0000gn/T/pip-install-sirxc970/django_b2
Discussions

python - How to install from a downloaded git repository - Stack Overflow
The easiest way to do this is most likely by first downloading using git and then installing with pip e.g. You can clone the repo again to assure non of your previous changes interfere with the installation. More on stackoverflow.com
🌐 stackoverflow.com
python - Is it possible to use pip to install a package from a private GitHub repository? - Stack Overflow
As an additional technique, if ... cloned locally, you can do: ... More modernly, you can just do this (and the -e will mean you don't have to commit changes before they're reflected): ... This was quite helpful. Apparently, local changes have to be git-commit'd before they can be installed via pip... More on stackoverflow.com
🌐 stackoverflow.com
Python Modules: Cloning from GitHub vs pip install
Hiya, Use the -e flag to install from github with pip: $ pip install -e git+ https://github.com/the-user/the-repo-name#egg=the-package-name More info here: http://pip.readthedocs.org/en/latest/reference/pip_install.html#vcs-support EDIT: My workflow with that flag: $ cd your-work-directory $ virtualenv venv $ source venv/bin/activate $ pip install -e git+https://github.com/the-user/the-repo-name#egg=the-package-name Now, the module's code you just fetched on github lives under the venv/src/your-module folder. It includes the .git folder and you can hack away now :) More on reddit.com
🌐 r/Python
4
5
April 16, 2014
python - How can I install from a git subdirectory with pip? - Stack Overflow
Also worth noting: When executing this from Windows command line, you must place the URL in double quotes, or you'll get an error "'subdirectory' is not recognized as an internal or external command". E.g., use pip install -e "git+myurl/proj#egg=subpkg&subdirectory=subdir" 2018-12-04T16:02... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GeeksforGeeks
geeksforgeeks.org › git › how-to-pip-install-from-a-git-repo-branch
How to Pip Install From a Git Repo Branch? - GeeksforGeeks
July 23, 2025 - pip install git+ 'address of repository'@name of branch ... Here is an example to clone repository https://github.com/username/repository with branch name branch_name
🌐
Squash
squash.io › how-to-pip-install-from-a-git-repo-branch
How to Pip Install From a Git Repo Branch - Squash Labs
November 2, 2023 - Using a virtual environment ensures that the installed package and its dependencies are isolated from the system-wide Python installation. As an alternative, you can directly specify the Git repository URL in the pip install command without cloning the repository manually.
🌐
PyPI
pypi.org › project › github-clone
github-clone · PyPI
July 4, 2021 - To clone private repositories you ...ing-a-personal-access-token-for-the-command-line). Install the script via the pip: pip install github-clone ·...
🌐
DEV Community
dev.to › fronkan › pip-install-a-git-repository-111b
Pip Install a Git Repository - DEV Community
July 19, 2022 - You could clone the repository and install it using pip locally: $ git clone https://github.com/pallets/flask.git $ pip install ./flask
Find elsewhere
🌐
Hashnode
fronkan.hashnode.dev › fredrik sjöstrand › #python › pip install a git repository
Pip Install a Git Repository - Fredrik Sjöstrand
October 22, 2020 - You could clone the repository and install it using pip locally: $ git clone https://github.com/pallets/flask.git $ pip install ./flask
🌐
Stack Abuse
stackabuse.com › bytes › installing-python-packages-from-a-git-repo-with-pip
Installing Python Packages from a Git Repo with pip
August 28, 2023 - $ pip install git+https://github.com/myuser/mypkg.git@dev · This command tells pip to install the dev branch of the mypkg repo. pip clones the repo, checks out the specified branch, and then installs the package.
🌐
Fir3net
fir3net.com › home › how to install a git repo using pip
How to install a Git Repo using Pip - Fir3net
July 31, 2021 - pip install -e git+https://github.com/felix001/commontools.git#egg=commontools
🌐
GitHub
gist.github.com › javrasya › e95ade856ff42e4649972f8a54368459
pip-install-from-a-git-repo.md · GitHub
#For Local Git Repository pip install git+file///path/to/your/git/project/ #Example: pip install git+file:///Users/ahmetdal/workspace/celery/
🌐
Reddit
reddit.com › r/python › python modules: cloning from github vs pip install
r/Python on Reddit: Python Modules: Cloning from GitHub vs pip install
April 16, 2014 -

So I've selected a Python project to contribute to from GitHub. I use the module that I've selected and am familiar with some portions of it. It would be cool if I were to complete my contribution and have it be accepted.

I have a few questions (are unfortunately very basic!) that I'd love some help with.

I'll start with a set-up question.

After cloning the project and getting a local copy, I can't import some of the modules even though it's in my PYTHONPATH. I see that class I want to import was downloaded from GitHub as <blah>.c.

When I try in another virtualenv python with said module installed via pip, the import work.

Does pip do any compilation? Do I need to do this manually when working with GitHub projects?

Is there a recommended way of doing this?

🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-install-a-python-package-from-a-github-repository
How to install a Python Package from a GitHub Repository - GeeksforGeeks
July 23, 2025 - Syntax: pip install "Package" @ git+"URL of the repository" ... Since the PIP package comes with the default installation of Python when we try to install pip from the GIT repository it shows that the Requirement is already satisfied.
Top answer
1 of 3
218

There is a pull request regarding this feature, and it seems to have been merged to develop branch a month ago. The syntax is the following:

pip install -e "git+https://git.repo/some_repo.git#egg=$NAME_OF_PACKAGE&subdirectory=$SUBDIR_IN_REPO" # install a python package from a repo subdirectory

We probably have to wait for a while until it gets merged to master and is distributed.

UPDATE: This is now available and documented at https://pip.pypa.io/en/stable/cli/pip_install/#vcs-support as follows:

For projects where setup.py is not in the root of project, "subdirectory" component is used. Value of "subdirectory" component should be a path starting from root of the project to where setup.py is located.

So if your repository layout is:

- pkg_dir/
  - setup.py  # setup.py for package ``pkg``
  - some_module.py
- other_dir/
  - some_file
- some_other_file

You'll need to use

pip install -e "vcs+protocol://repo_url/#egg=pkg&subdirectory=pkg_dir"

Note: Make sure to surround it with quotes otherwise subdirectory won't work.

2 of 3
50

It's been already stated in one of the comments under the correct answer, but just to highlight this issue: when executing this from Linux command line, you must escape the &-character since ampersand is telling the command line to run a command in background:

git+https://git.repo/some_repo.git#egg=version_subpkg\&subdirectory=repo

Notice the backslash before the ampersand. The escaping behaviour might depend on the Linux distro; I'm not an expert.
If you ignore this, you might run into a cryptic error like the following:

bash: (...) command not found
🌐
GitHub
github.com › gitpython-developers › GitPython
GitHub - gitpython-developers/GitPython: GitPython is a python library used to interact with Git repositories. · GitHub
If you are cloning your own fork, ... have gh and your fork is called GitPython): ... Having cloned the repo, create and activate your virtual environment. ... In the less common case that you do not want to install test dependencies, pip install -e ...