How to install a Python Package from a GitHub Repository
Last Updated :
28 Dec, 2022
In this article we will learn how to install a pip package from a git repository, PIP supports installing from various version control systems (VCS). This support requires a working executable to be available (for the version control system being used). It is used through URL prefixes:
- Git -- git+
- Mercurial -- hg+
- Subversion -- svn+
- Bazaar -- bzr+
Install pip package from a Git repository
How pip install it from a git repository
Initially install, pip will Clone the repository and fetch and check out the desired commit than it will build the package into a wheel it install that wheel and their dependencies (if any).
To install the PIP package run the following command
Syntax: pip install "Package" @ git+"URL of the repository"
pip install pip@git+https://github.com/pypa/pip
Output:
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.
Installing specified PIP version
Here, you have to replace the version commit with the git commit of the version you want to install, later in this article, we will see how to install from commits and subdirectories and name the project also.
pip install pip@git+https://github.com/pypa/pip@'version commit'
Output:
In the output image, we can clearly see that first the version of pip was 22.2.1 and after installing the specified new commit version it is changed to 23.0
Installing NumPy from GIT Repository
pip install GFG@git+https://github.com/numpy/numpy
Installing the pyClip from the GIT repository
pip install clip@git+https://github.com/spyoungtech/pyclip
You can see that package is installed successfully.
Install Specific Project from a GitHub Repository
For specifying the "project name" use #egg=<pkg_name> and add it at the end.
pip install "Package" @ git+"URL of the repository#egg=<pkg_name>"
For example, installing NumPy.
pip install GFG @ git+https://github.com/numpy/numpy#egg=Numpy
For example, installing an emoji module.
pip install emoji@git+https://github.com/carpedm20/emoji#egg=EMOJI
Install Subdirectory of the GitHub Repository
If the project you want to install is in a subdirectory of the repository not on the root, in that case, add #subdirectory=<path> at the end
pip install "Package" @ git+"URL of the repository#subdirectory=path"
For example, installing the NumPy subdirectory:
pip install GFG @ git+https://github.com/numpy/numpy#subdirectory=numpy
Similar Reads
How to Install a Python Package with a .whl File? To install a Python package using a .whl (wheel) file, you'll need to follow a few simple steps. The first method involves using PowerShell along with pip and the cd command to change the directory to where your .whl file is located. The second method uses PowerShell and pip directly, without changi
4 min read
How to Pip Install From a Git Repo Branch? While working with a project in git, you'll often find yourself in the position where you want to install some software for any purpose like testing bugs. This is done using the 'pip' command and it is important to understand how we can use this command to install a package from a specific branch of
5 min read
How to Automatically Install Required Packages From a Python Script? When working in python having to use libraries you don't know or using a new pc, it is a hectic job to install all the libraries one by one. Each time you have to find out the name of the library and install it one by one. But if we know libraries like pipreqs which automatically installs all the re
2 min read
How to Install Python Package in Google's Colab Installing a Python package in Google Colab is like going on a space adventure with your keyboard as a trusty spaceship. Don't worry, fellow coder, the world of Python packages is ready for your exploration. with just a few lines of code, you can easily bring in the tools for your coding adventure.
3 min read
How to Install an NPM Package Directly from GitHub ? Installing npm packages directly from GitHub can be incredibly useful, especially when you need to use a specific version or branch of a package that may not yet be published to the npm registry. This approach allows developers to take advantage of the latest features, bug fixes, or specific package
2 min read