Installing Private Python Packages¶
This guide is for Read the Docs for Business.
From a Git repository¶
Pip supports installing packages from a Git repository using the URI form:
Or if your repository is private:
version can be a tag, a branch, or a commit.
token is a personal access token with read only permissions from your provider.
To install the package, you need to add the URI in your requirements file. Pip will automatically expand environment variables in your URI, so you don’t have to hard code the token in the URI. See using environment variables in Read the Docs for more information.
You have to use the POSIX format for variable names (only uppercase letters and
_ are allowed),
and including a dollar sign and curly brackets around the name (
for pip to be able to recognize them.
Below you can find how to get a personal access token from our supported providers. We will be using environment variables for the token.
You need to create a personal access token with the
Check the GitHub documentation
on how to create a personal token.
GitHub doesn’t support tokens per repository. A personal token will grant read and write access to all repositories the user has access to. You can create a machine user to give read access only to the repositories you need.
You need to create a deploy token with the
read_repository scope for the repository you want to install the package from.
Check the GitLab documentation
on how to create a deploy token.
GITLAB_TOKEN_USER is the user from the deploy token you created, not your GitLab user.
You need to create an app password with
Read repositories permissions.
Check the Bitbucket documentation
on how to create an app password.
BITBUCKET_USER is your Bitbucket user.
Bitbucket doesn’t support app passwords per repository. An app password will grant read access to all repositories the user has access to.
From a repository manager other than PyPI¶
Pip by default will install your packages from PyPI.
If you are using a repository manager like pypiserver, or Nexus Repository,
you need to set the
You have two ways of set that option:
PIP_INDEX_URLenvironment variable in Read the Docs with the index URL. See https://pip.pypa.io/en/stable/reference/requirements-file-format#using-environment-variables.
--index-url=https://my-index-url.com/at the top of your requirements file. See Requirements File Format.
Check your repository manager’s documentation to obtain the appropriate index URL.