question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`pipenv install --index <my-pypi-registry> <my-package>` generates a Pipfile that `pipenv lock` can't handle

See original GitHub issue

I start from a completely blank slate – no Pipfile, no Pipfile.lock, no virtual environment. And I execute a command like

pipenv install --index <my-pypi-registry> <my-package>

where <my-pypi-registry> is a private PyPI registry (not a mirror of the public PyPI registry!) that hosts the package <my-package>.

The result of the command is:

  • a virtual environment is successfully created
  • and a Pipfile is generated
  • but locking fails.
...
Successfully created virtual environment!
Virtualenv location: C:\tmp\tmp-venv\.venv
Creating a Pipfile for this project...
Installing <my-package>...
Adding <my-package> to Pipfile's [packages]...
Installation Succeeded
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
 Locking...Building requirements...
Resolving dependencies...
Locking Failed!

CRITICAL:pipenv.patched.notpip._internal.resolution.resolvelib.factory:Could not find a version that satisfies the requirement <my-package> (from versions: none)
[ResolutionFailure]:   File "c:\python391\lib\site-packages\pipenv\resolver.py", line 743, in _main
[ResolutionFailure]:       resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
[ResolutionFailure]:   File "c:\python391\lib\site-packages\pipenv\resolver.py", line 704, in resolve_packages
[ResolutionFailure]:       results, resolver = resolve(
[ResolutionFailure]:   File "c:\python391\lib\site-packages\pipenv\resolver.py", line 685, in resolve
[ResolutionFailure]:       return resolve_deps(
[ResolutionFailure]:   File "c:\python391\lib\site-packages\pipenv\utils.py", line 1370, in resolve_deps
[ResolutionFailure]:       results, hashes, markers_lookup, resolver, skipped = actually_resolve_deps(
[ResolutionFailure]:   File "c:\python391\lib\site-packages\pipenv\utils.py", line 1099, in actually_resolve_deps
[ResolutionFailure]:       resolver.resolve()
[ResolutionFailure]:   File "c:\python391\lib\site-packages\pipenv\utils.py", line 877, in resolve
[ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: No matching distribution found for <my-package>

The generated Pipfile looks like this:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
<my-package> = {version = "*", index = "<my-pypi-registry>"}
...

That looks reasonable, but pipenv lock fails on it with the error shown above.

However, if I manually change the Pipfile to look like this, then pipenv lock succeeds, even though this seems essentially the same:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[[source]]
url = "<my-pypi-registry>"
verify_ssl = true
name = "mypypi"

[packages]
<my-package> = {version = "*", index = "mypypi"}
...

If (again starting from a completely blank slate) I replace --index with --extra-index-url, so my command looks like this:

pipenv install --extra-index-url <my-pypi-registry> <my-package>

then the command’s output looks the same, meaning

  • a virtual environment is successfully created
  • and a Pipfile is generated
  • but locking fails with the same error as above.

However, in this case, the generated Pipfile is clearly wrong, in that it doesn’t reference <my-pypi-registry> at all, so it’s not surprising that pipenv lock fails on it. It looks like this:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
<my-package> = "*"
...

In summary, this might be two separate bugs.

  1. pipenv lock fails on the seemingly correct Pipfile generated by pipenv install --index ....
  2. pipenv install --extra-index-url ... generates an incorrect Pipfile.

I’m using pipenv version 2021.11.15, which I installed using pip.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
Yuribtrcommented, Mar 28, 2022

Seems this problem resurrected in last release 2022.3.28 (at least). I was unable to install python packages from my private repository. The same problem raised:

CRITICAL:pipenv.patched.notpip._internal.resolution.resolvelib.factory:Could not find a version that satisfies the requirement my-utils (from versions: none)

Pipfile is:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[[source]]
url = "http://nexus.localhost:8081/repository/pypi-internal/simple/"
verify_ssl = false
name = "nexus"

[dev-packages]
ipython = "*"
pytest = "*"
pytest-env = "*"
pytest-cov = "*"
flake8 = "*"
flake8-broken-line = "*"
flake8-builtins = "*"
flake8-commas = "*"
flake8-comprehensions = "*"
flake8-mutable = "*"
flake8-print = "*"
flake8-cognitive-complexity = "*"
flake8-functions = "*"
flake8-quotes = "*"
pre-commit = "*"
requests = "*"

[packages]
fastapi = "*"
uvicorn = "*"
gunicorn = "*"
python-json-logger = "*"
markdown2 = "*"
my-utils = {extras = ["fastapi"], version = "*",  index = "nexus"}

[requires]
python_version = "3.9"

[pipenv]
allow_prereleases = false

Also another problem raised, if in Pipfile I swap sources like this:

[[source]]
url = "http://nexus.localhost:8081/repository/pypi-internal/simple/"
verify_ssl = false
name = "nexus"

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

........

In above case I get:

CRITICAL:pipenv.patched.notpip._internal.resolution.resolvelib.factory:Could not find a version that satisfies the requirement flake8-comprehensions (from versions: none)

Solution: pip install "pipenv==2022.1.8"

0reactions
matteiuscommented, Apr 4, 2022

@bkraft4257 This is a closed issue you are commenting on, and also you did not indicate the version of pipenv you are running or the contents of an example Pipfile. If you would like support please ensure you are running the latest version, have checked recent opened issues and potentially file a new issue report. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common Pipenv Errors and How to Solve Them: Why Won't it ...
Here, you'll learn how to troubleshoot Pipenv installation and locking issues. ... creates a virtual environment, a Pipfile, and a Pipfile.lock.
Read more >
Advanced Usage of Pipenv - Read the Docs
Dependencies of wheels provided in a Pipfile will not be captured by $ pipenv lock . There are some known issues with using...
Read more >
How to fix locking failed in pipenv? - Stack Overflow
Just delete the Pipfile.lock then rerun pipenv lock .
Read more >
pipenv install [package] - Fig.io
Initializes a package manager or installs all packages from Pipfile. ... --deploy, Enforce that your Pipfile.lock is up to date in deployment.
Read more >
pipenv Documentation - Read the Docs
Generates and checks file hashes for locked dependencies when installing from Pipfile.lock. • Automatically install required Python version when pyenv is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found