73

I am using pipenv to handle Python package dependencies.

The Python package is using two packages (named pckg1 and pckg2) that rely on the same package named pckg3, but from two different versions. Showing the dependency tree :

$ pipenv graph
  pckg1==3.0.0
    - pckg3 [required: >=4.1.0]
  pckg2==1.0.2
    - pckg3 [required: ==4.0.11]

An attempt to install dependencies :

$ pipenv install

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.
Could not find a version that matches pckg3==4.0.11,==4.1.0,>=4.1.0 (from -r C:\Users\user\AppData\Local\Temp\pipenv-o7uxm080-requirements\pipenv-hwekv7dc-constraints.txt (line 2))
Tried: 3.3.1, 3.3.2, 3.3.3, 3.4.0, 3.4.2, 4.0.0, 4.0.0, 4.0.1, 4.0.1, 4.0.2, 4.0.2, 4.0.3, 4.0.3, 4.0.4, 4.0.4, 4.0.6, 4.0.6, 4.0.8, 4.0.8, 4.0.9, 4.0.9, 4.0.10, 4.0.10, 4.0.11, 4.0.11, 4.1.0, 4.1.0, 4.1.1, 4.1.1, 4.1.2, 4.1.2, 4.2.1, 4.2.1, 4.3.0, 4.3.0
There are incompatible versions in the resolved dependencies.

As suggested, pip install --skip-lock does the trick, but the dependency tree is still unresolved.

I would love to tell Pipenv to override pckg2's requirement, and specify pckg3>=4.1.0.

How can this be resolved?

Val Berthe
  • 1,899
  • 1
  • 18
  • 33

14 Answers14

79

I get that error constantly. Clearing the cache in the lock file works beautifully every time.

$ pipenv lock --pre --clear

arshbot
  • 12,535
  • 14
  • 48
  • 71
  • 5
    This is helpful, but I had to do it without the `--pre` or I got other mismatch errors. – Marc Nov 02 '18 at 13:45
  • combining @northtree with Harsha Goli did the trick......but still have no real understanding of what the underlieing issue was :( – Jake Feb 25 '19 at 18:10
  • It most often means there are invalid inconsistencies with the pipfile.lock. Sometimes this can genuinely happen if there is a dependency conflict - but this answer is tailored for when pipenv simply needs to dump it's cache and recreate the lock file – arshbot Feb 03 '20 at 21:03
  • on my mac I can not use `pipenv lock --pre --clear` but it work only when i say `python3.9 -m pipenv lock --pre --clear` any help? – Ali Husham May 27 '21 at 06:56
  • 1
    In my own situation I get the dependency error when I run `pipenv lock --pre --clear`. – Chidiebere Jun 02 '21 at 13:32
  • ``` ERROR: Could not find a version that matches werkzeug<2.0.0,>=0.7,>=2.0 (from -r /var/folders/2y/061kgpfx29110d440z4w1ft40000gn/T/pipenvr4na45z1requirements/pipenv-ez8fnckw-constraints.txt (line 28)) Tried: 0.1, 0.2, 0.3, 0.3.1, 0.4, 0.4.1, 0.5, 0.5.1, 0.6, 0.6.1, 0.6.2, 0.7, 0.7.1, 0.7.2, 0.8, 0.8.1, 0.8.2, 0.8.3, 0.9, 0.9.1, 0.9.2, 0.9.3, 0.9.4, 0.9.5, 0.9.6, 0.10, 0.10.1, 0.10.2, 0.10.2, 0.10.4, 0.10.4, 0.11, 0.11, 0.11.1, 0.11.1, 0.11.2, 0.11.2, 0.11.3, 0.11.3, 0.11.4, 0.11.4, 0.11.5, 0.11.5, 0.11.6, ... ``` – Chidiebere Jun 02 '21 at 13:33
19

You can't. At the moment, pipenv doesn't offer anything for an explicit override of requirement constraints.

As a workaround, you can put dependencies that you want to override to dev-packages as those will be overridden by packages, so this Pipfile should install pckg3>=4.1.0:

# Pipfile
...
[packages]
pckg1 = "==3.0.0"

[dev-packages]
pckg2 = "==1.0.2"

If you now lock and install:

$ pipenv lock --dev
$ pipenv install --dev

the requirement ==4.0.11 will be overridden by >=4.1.0. This is ugly if you ask me because this is not what development packages are meant for and you're changing the role of pckg2 dependency in project, but I don't see any better way here.

hoefling
  • 59,418
  • 12
  • 147
  • 194
  • Overriding dependencies in `dev-package` works, but I really dislike putting non-dev packages in the dev packages list... – Val Berthe Aug 08 '18 at 09:59
  • 2
    I agree that stinks (mentioned that in the answer), but I'm afraid there's no other option available with `pipenv`'s current development state... – hoefling Aug 12 '18 at 16:31
  • @hoefling I don't understand how `3.0.0` and `1.0.2` is yaml are related to `==4.0.11 ` and `>=4.1.0` in your explanation – abhiieor May 12 '21 at 21:21
  • @abhiieor check out the output of `pipenv graph` in the question - the first two are versions of direct dependencies, the last two are conflicting versions of the same transient dependency. Overall, this answer may be obsolete, I don't use `pipenv` anymore. – hoefling May 12 '21 at 21:29
5

This works when there are unfinished routines on pipfile.

Once I made a mistake and run

pipenv install codecove # With an 'e' at the end

and the pipenv kept always trying to complete the installation with no success because the lib does not exist. I resolved it with:

pipenv uninstall codecove

and installed codecov after.

I tried to run

pipenv lock --clear
pipenv lock --pre --clear

but only after uninstalled the lib with wrong name I succeeded.

  • 1
    Yes it's very stupid! Even if I try to install `pipenv install WrongName`: Of course, it will fail to install but in addition it will make `pipenv` unable to install everything after that! So i need to do after that: `pipenv uninstall WrongName`... – ThePhi May 29 '20 at 10:09
3

I have the similar issue with google-cloud-core.

$ pipenv lock
Locking [dev-packages] dependencies…
Locking [packages] dependencies…

Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, 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.
Could not find a version that matches google-cloud-core<0.29dev,<0.30dev,>=0.28.0,>=0.29.0
Tried: 0.20.0, 0.20.0, 0.21.0, 0.21.0, 0.22.0, 0.22.0, 0.22.1, 0.22.1, 0.23.0, 0.23.0, 0.23.1, 0.23.1, 0.24.0, 0.24.0, 0.24.1, 0.24.1, 0.25.0, 0.25.0, 0.26.0, 0.26.0, 0.27.0, 0.27.0, 0.27.1, 0.27.1, 0.28.0, 0.28.0, 0.28.1, 0.28.1, 0.29.0, 0.29.0
There are incompatible versions in the resolved dependencies.

It was solved by

  1. rm -rf Pipfile.lock
  2. pipenv update
northtree
  • 8,569
  • 11
  • 61
  • 80
2

If you get an error like:

Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✘ Locking Failed! 

For me, this happened because the underlying virtual environment did not refer to my current directory.

I solved this problem by moving the contents to a new directory and deleting the old one.

I also had to delete the Pipfile and Pipfile.lock but I'm not sure if that's necessary.

Connor
  • 4,216
  • 2
  • 29
  • 40
1

It happened the same to me, I'm working with Visual Studio Code and I was able to get rid o it:

  • remove all files except *.py from your python folder (.vscode, pycache, * virtual environments within that folder)
  • create a new virtualenv env(name)
  • new\scripts\activate.bat

and then try to install the missing dependencies for the virtual folder and good to go, it worked for me.

jthalliens
  • 504
  • 4
  • 14
1

Nothing here worked for me. In the end this solved the issue:

pip uninstall pipenv
pip install pipenv
dev-jeff
  • 173
  • 9
1

If you ran into the Locking Failed! error:

Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✘ Locking Failed!

Clearing the cache on pipfile.lock, uninstalling your package and restarting the VM did the trick for me.

Try:

pipenv uninstall *YourPackage*
pipenv uninstall *YourPackage* --dev   ##(if relevant to your package)
pipenv lock --clear

stop & destroy VM

restart VM

Hope this helps!

Galf
  • 15
  • 4
0

I had similar issue with glob module. I deleted glob = "*" from Pipfile and it worked fine after that.

Error:

bash-4.2# pipenv lock  --clear
Locking [dev-packages] dependencies…
✔ Success! 
Locking [packages] dependencies…
✘ Locking Failed! 
[pipenv.exceptions.ResolutionFailure]:   File "/root/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pipenv/resolver.py", line 69, in resolve
[pipenv.exceptions.ResolutionFailure]:       req_dir=requirements_dir
[pipenv.exceptions.ResolutionFailure]:   File "/root/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pipenv/utils.py", line 726, in resolve_deps
[pipenv.exceptions.ResolutionFailure]:       req_dir=req_dir,
[pipenv.exceptions.ResolutionFailure]:   File "/root/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]:   File "/root/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pipenv/utils.py", line 395, in resolve
[pipenv.exceptions.ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches glob
[pipenv.exceptions.ResolutionFailure]:       No versions found
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, 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: ERROR: Could not find a version that matches glob
No versions found
Was https://pypi.org/simple reachable?
[pipenv.exceptions.ResolutionFailure]:       req_dir=requirements_dir
[pipenv.exceptions.ResolutionFailure]:   File "/root/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pipenv/utils.py", line 726, in resolve_deps
[pipenv.exceptions.ResolutionFailure]:       req_dir=req_dir,
[pipenv.exceptions.ResolutionFailure]:   File "/root/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]:   File "/root/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pipenv/utils.py", line 395, in resolve
[pipenv.exceptions.ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches glob
[pipenv.exceptions.ResolutionFailure]:       No versions found
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, 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: ERROR: Could not find a version that matches glob
No versions found
Was https://pypi.org/simple reachable?
Ash
  • 1,180
  • 3
  • 22
  • 36
0

On Windows 10 using VS Code I got a clean install after much messing about by running pipenv in Powershell. I also deleted all traces of the previous tries (new directory deleted the previous venvs).

Townheadbluesboy
  • 265
  • 2
  • 4
  • 16
0
pip install -U pipenv     

solved for me on Ubuntu 21.04 - Hirsute Hippo - python Version 3.9.5

This command installed those packages:

  • appdirs-1.4.4
  • certifi-2021.5.30
  • distlib-0.3.2
  • filelock-3.0.12
  • pipenv-2021.5.29
  • six-1.16.0
  • virtualenv-20.4.7
  • virtualenv-clone-0.5.4
Nontro
  • 9
  • 1
0

Updating pip inside the virtualenv worked for me: py -m pip install --upgrade pip

Wesley Cheek
  • 1,058
  • 12
  • 22
0

This could also be because you had an old pipenv environment and you need to clean it before you create a new one.

pipenv --rm
pipenv install
carkod
  • 1,844
  • 19
  • 32
-2
pipenv lock
Locking [dev-packages] dependencies…
Locking [packages] dependencies…

Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, 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.

pipenv install --clean

ZeroDeth
  • 7
  • 4