How to resolve Python package depencencies with pipenv?

后端 未结 12 2505
余生分开走
余生分开走 2020-12-13 06:35

I am using pipenv to handle a Python package dependencies.

The Python package is using two packages (named pckg1 and pckg2) that relies on

相关标签:
12条回答
  • 2020-12-13 06:56

    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.

    0 讨论(0)
  • 2020-12-13 06:56

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

    pip uninstall pipenv
    pip install pipenv
    
    0 讨论(0)
  • 2020-12-13 07:01

    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.

    0 讨论(0)
  • 2020-12-13 07:02

    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
    0 讨论(0)
  • 2020-12-13 07:02

    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.

    0 讨论(0)
  • 2020-12-13 07:06

    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).

    0 讨论(0)
提交回复
热议问题