How to install from a downloaded git repository
Categories:
Installing Python Packages from a Downloaded Git Repository

Learn how to install Python packages directly from a local Git repository using pip, covering both editable and standard installations.
When developing Python applications, you often encounter situations where you need to install a package that isn't yet published to PyPI, or you're working on a local fork of a project. Installing directly from a downloaded Git repository allows you to use the latest development version, make local modifications, or test unreleased features. This guide will walk you through the process of installing such packages using pip
.
Understanding the Installation Process
Installing from a local Git repository involves pointing pip
to the directory containing the package's setup.py
or pyproject.toml
file. There are two primary methods: a standard installation and an editable installation. The choice depends on whether you intend to modify the package's source code directly within your project's environment.
flowchart TD A[Start] --> B{Downloaded Git Repo?} B -- Yes --> C[Navigate to Repo Root] C --> D{Editable Install?} D -- Yes --> E["pip install -e ."] D -- No --> F["pip install ."] E --> G[Package Linked/Installed] F --> G G --> H[End]
Flowchart for installing a Python package from a local Git repository.
Prerequisites
Before you begin, ensure you have the following:
1. Python and pip installed
You should have Python 3.x and pip
(Python's package installer) installed and configured in your system's PATH. You can verify this by running python --version
and pip --version
in your terminal.
2. Git installed
Git must be installed on your system to clone repositories. Verify with git --version
.
3. Downloaded Git Repository
You need a local copy of the Git repository. This can be obtained by cloning it using git clone <repository_url>
or by downloading a ZIP archive and extracting it.
Standard Installation
A standard installation copies the package files into your Python environment's site-packages
directory. This is suitable when you don't plan to make direct changes to the package's source code within your project.
1. Navigate to the repository directory
Open your terminal or command prompt and change your current directory to the root of the downloaded Git repository. This is the directory containing the setup.py
or pyproject.toml
file.
2. Install the package
Run the following pip
command. The .
signifies the current directory.
cd /path/to/your/downloaded/repo
pip install .
Standard installation command for a local package.
python -m venv venv
and activate it with source venv/bin/activate
(Linux/macOS) or .\venv\Scripts\activate
(Windows PowerShell).Editable Installation
An editable installation (also known as 'development mode') creates a link in your Python environment's site-packages
directory that points directly to the source code in your local Git repository. This means any changes you make to the source files in the repository are immediately reflected in your Python environment without needing to reinstall the package. This is ideal for developing or debugging the package itself.
1. Navigate to the repository directory
Just like with a standard installation, navigate to the root of your downloaded Git repository in your terminal.
2. Perform an editable install
Use the -e
(or --editable
) flag with pip install
:
cd /path/to/your/downloaded/repo
pip install -e .
Editable installation command for a local package.
pip install
.Verifying the Installation
After installation, you can verify that the package is available by trying to import it in a Python interpreter or by listing installed packages.
pip list | grep your_package_name
Verify package installation using pip list.
import your_package_name
print(your_package_name.__version__)
Verify package import in Python.
setup.py
or pyproject.toml
, pip
might not install them automatically. You may need to install them manually or ensure the package's configuration files are correct.