Pipenv doesn't natively support installing packages directly from specific Git branches. However, you can achieve this by specifying the package's Git repository URL along with the desired branch using the -e
flag, which tells Pipenv to install the package in editable mode. Here's how you can do it:
Navigate to Your Project Directory:
Open a terminal or command prompt and navigate to the directory of your Python project where your Pipfile
and Pipfile.lock
are located.
Install the Package from Git Branch:
Run the following command, replacing GIT_REPO_URL
with the URL of the Git repository and BRANCH_NAME
with the name of the branch you want to install:
pipenv install -e git+GIT_REPO_URL@BRANCH_NAME#egg=PACKAGE_NAME
For example:
pipenv install -e git+https://github.com/username/repo.git@development#egg=my-package
In this example, my-package
is the name you'll use to reference the package in your code.
Edit Your Pipfile:
After running the above command, Pipenv will add an entry to your Pipfile
under the [packages]
section. It will look something like:
my-package = {editable = true,git = "https://github.com/username/repo.git",ref = "development"}
Install Dependencies: Run the following command to install the dependencies, including the one from the Git branch:
pipenv install
Remember that the ability to install specific Git branches directly using pipenv
depends on the state of the tool at the time of your usage.
How to install a specific git branch with pipenv?
pipenv install git+https://github.com/user/repository.git@branch_name
How to install a specific git branch with pipenv from a private repository?
pipenv install git+https://username:password@github.com/user/repository.git@branch_name
How to install a specific git branch with pipenv using SSH authentication?
pipenv install git+ssh://git@github.com/user/repository.git@branch_name
How to install a specific git branch with pipenv from a subdirectory of the repository?
pipenv install git+https://github.com/user/repository.git@branch_name#subdirectory=path/to/package
How to install a specific git branch with pipenv from a specific commit?
pipenv install git+https://github.com/user/repository.git@commit_hash
How to install a specific git branch with pipenv using SSH and a specific commit?
pipenv install git+ssh://git@github.com/user/repository.git@commit_hash
How to update an existing package to a specific git branch with pipenv?
--update
flag followed by the package name and the git branch.pipenv update package_name@git+https://github.com/user/repository.git@branch_name
How to install a specific git branch with pipenv for development purposes?
-e
or --editable
flag along with the URL and branch name.pipenv install -e git+https://github.com/user/repository.git@branch_name#egg=package_name
How to install a specific git branch with pipenv using a requirements.txt file?
-r
flag.pipenv install -r requirements.txt
headless nslocale securestring mongodb refactoring google-authenticator r-faq signals java.util.calendar modulus