pip --extra-index-url vs --index-url, and the dependency confusion trap
Serving developers since 2016 Founder-run, no venture capital MFA, SSO and audit log on every plan
Every feature on every plan, with unlimited users. 14 days free. No credit card required.
Start free trialStarting at $99/month billed annually.
--index-url tells pip to use one index instead of PyPI. --extra-index-url adds a second index alongside it, and pip searches both together, installing the best version it finds in either place. If your private package lives on your own index, a package with the same name on PyPI can be installed instead.
pip’s documentation warns: “Using the –extra-index-url option to search for packages which are not in the main repository (for example, private packages) is unsafe.” (pip install, read 2026-11-18)
To avoid this, install your private packages from your private index alone with --index-url, and install public packages from PyPI in a separate step.
What each flag does
| Flag | Environment variable | What pip does |
|---|---|---|
--index-url URL (-i) |
PIP_INDEX_URL |
Reads this index instead of PyPI. |
--extra-index-url URL |
PIP_EXTRA_INDEX_URL |
Reads this index as well as the first. |
pip’s documentation describes --index-url as the “Base URL of the Python Package Index (default https://pypi.org/simple)”, and --extra-index-url as “Extra URLs of package indexes to use in addition to –index-url.” (pip install, read 2026-11-18)
In pip.conf, the same two settings are index-url and extra-index-url.
CloudRepo, JFrog Artifactory and Sonatype Nexus, side by side
| Question | CloudRepo Essentials | JFrog Artifactory Cloud Pro | Sonatype Nexus Pro Cloud |
|---|---|---|---|
| Included each month | 10 GB storage and 250 GB transfer | 25 GB, then $1.25/GB storage and transfer counted together [1] | 25 GB, then $1.10/GB of consumption [2] |
| Users | Unlimited, on every plan | Typically up to 50 users how JFrog sizes Pro [1] | New contracts are priced by consumption [3] |
| Support | Human support, on every plan | Community support: public documentation, a knowledge base and Stack Overflow [4] | Pro lists enterprise support, SLA and migration services as available [2] |
Every feature on every plan
Start free trial Or compare your Sonatype or JFrog quote with ours
14 days free. No credit card required.
Starting at $99/month billed annually.
Sources (4): each vendor's own pages, read 2026-10-06 to 2026-10-21. Prices as each vendor listed them on the date shown.
- JFrog pricing, read (archived)
- Sonatype pricing, read (archived)
- Sonatype pricing, read
- JFrog pricing, read
(archived)
Community Support - Available for Free solutions and Pro subscriptions - JFrog maintains public documentation, knowledge base, and engages in conversations on Stack Overflow.
Why a second index is a trap
pip does not check your index first and fall back to PyPI. The documentation states: “There is no priority in the locations that are searched.” (pip install, read 2026-11-18) It checks every index and installs the best match by version number.
Say your private package is acme-billing 1.4.0 on your own index. Someone publishes acme-billing 99.0.0 on PyPI. With --extra-index-url, pip sees both and picks 99.0.0 as the better match. That is dependency confusion.
An exact pin is not enough either. Anyone can publish a package on PyPI under your private package’s name, and acme-billing==1.4.0 does not help when both indexes have that version.
The setup: one index per install
You need a Python repository in CloudRepo and a repository token with access to it. A token with Download packages access is enough to install. If you don’t have those yet, create a repository and create a token.
1. Put the token in ~/.netrc
pip reads the credential for your index’s host from ~/.netrc, so the index URL doesn’t need one. The login is the email address of the account that created the token, and the password is the token:
machine your-org.mycloudrepo.iologin you@example.compassword YOUR_REPOSITORY_TOKENKeep the file readable only by you: chmod 600 ~/.netrc.
2. Install in three steps
Install public packages from PyPI first, then your private packages from CloudRepo alone, and finally your own project without its dependencies (steps 1 and 2 already installed them):
pip install -r requirements.txtpip install -r requirements-private.txtpip install --no-deps -e .requirements-private.txt sets CloudRepo as its only index:
--index-url https://your-org.mycloudrepo.io/repositories/your-repo/simple/acme-billing==1.4.0The --index-url line makes CloudRepo the only index for that command. pip reads the login from ~/.netrc, so the file has no credentials and you can commit it.
For this split to work:
- Keep private package names out of
requirements.txt. Nothing installed in step 1 can depend on a private package (including your own project), or pip will look for it on PyPI. - List the public dependencies of your private packages in
requirements.txt. Step 2 will find them already installed, and if one is missing, step 2 fails rather than looking on PyPI. - Leave pip’s default index as PyPI. For this setup, don’t set
index-urlinpip.conforPIP_INDEX_URLin your shell, since step 1 reads PyPI.
If your project’s build needs a private package, the Python install guide shows what to change.
This is the setup the CloudRepo portal shows for a hosted Python repository, and we test it with the real pip.
Or give pip one index URL (early access)
A PyPI group gives pip one index URL for your hosted repositories and a proxy repository of PyPI. pip then reads one index for every name, so it has no second index to compare. PyPI groups are in early access. PyPI groups shows how to set one up.
If pip asks for a username
When CloudRepo refuses the credential in ~/.netrc, pip does not show the 401. It asks User for your-org.mycloudrepo.io: instead. In CI, where nobody can answer, pip stops with EOFError: EOF when reading a line. Check these:
- The
loginis the email address of the account that created the token, and themachineline names your index’s host. - The
passwordis the token itself. A placeholder login, such as the one pypi.org uses for its tokens, is refused. - The token is still active. An expired or revoked token fails the same way, and the Repository Tokens page in the admin portal shows its status.
Every feature on every plan, with unlimited users
14 days free. No credit card required.
Starting at $99/month billed annually.
Founder-run since 2016, with no venture capital. A real person answers within one business day. Usually it's me.
Chris, founder of CloudRepo