pipenv: pipenv respects version constraint from incorrect python version

drf-yasg package has 2 Django version constraints:

Django (>=1.11.7); python_version >= "3.4"
Django (<2.0,>=1.11.7); python_version <= "2.7"

pipenv uses 2.7 one even when invoked in python 3.6 virtual env.

$ python -m pipenv.help output

Pipenv version: '11.10.0'

Pipenv location: '/Users/dspeck/work/test/.venv/lib/python3.6/site-packages/pipenv'

Python location: '/Users/dspeck/work/test/.venv/bin/python'

Other Python installations in PATH:

  • 2.7: /usr/bin/python2.7

  • 2.7: /usr/bin/python2.7

  • 3.6: /usr/local/bin/python3.6m

  • 3.6: /Users/dspeck/work/test/.venv/bin/python3.6

  • 3.6: /usr/local/bin/python3.6

  • 3.6.4: /Users/dspeck/work/test/.venv/bin/python

  • 3.6.4: /usr/local/bin/python

  • 2.7.10: /usr/bin/python

  • 3.6.4: /Users/dspeck/work/test/.venv/bin/python3

  • 3.6.4: /usr/local/bin/python3

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.6.4',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '17.5.0',
 'platform_system': 'Darwin',
 'platform_version': 'Darwin Kernel Version 17.5.0: Mon Mar  5 22:24:32 PST '
                     '2018; root:xnu-4570.51.1~1/RELEASE_X86_64',
 'python_full_version': '3.6.4',
 'python_version': '3.6',
 'sys_platform': 'darwin'}

System environment variables:

  • TERM_SESSION_ID
  • SSH_AUTH_SOCK
  • Apple_PubSub_Socket_Render
  • COLORFGBG
  • ITERM_PROFILE
  • XPC_FLAGS
  • PWD
  • SHELL
  • SECURITYSESSIONID
  • LC_CTYPE
  • TERM_PROGRAM_VERSION
  • TERM_PROGRAM
  • PATH
  • COLORTERM
  • COMMAND_MODE
  • TERM
  • HOME
  • TMPDIR
  • USER
  • XPC_SERVICE_NAME
  • LOGNAME
  • __CF_USER_TEXT_ENCODING
  • ITERM_SESSION_ID
  • SHLVL
  • OLDPWD
  • ZSH
  • PAGER
  • LESS
  • LSCOLORS
  • PROMPT_EOL_MARK
  • VIRTUAL_ENV_DISABLE_PROMPT
  • LC_ALL
  • LANG
  • PIPENV_VENV_IN_PROJECT
  • ANDROID_HOME
  • VIRTUAL_ENV
  • _
  • PYTHONDONTWRITEBYTECODE
  • PIP_PYTHON_PATH
  • PYTHONUNBUFFERED

Pipenv–specific environment variables:

  • PIPENV_VENV_IN_PROJECT: yes

Debug–specific environment variables:

  • PATH: /Users/dspeck/work/test/.venv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/dspeck/Library/Android/sdk/tools:/Users/dspeck/Library/Android/sdk/platform-tools
  • SHELL: /bin/zsh
  • LANG: en_US.UTF-8
  • PWD: /Users/dspeck/work/test
  • VIRTUAL_ENV: /Users/dspeck/work/test/.venv

Contents of Pipfile (‘/Users/dspeck/work/test/Pipfile’):

[packages]
django = ">=2.0"
drf-yasg = "*"

Expected result

pipenv lock produces Pipfile.lock

Actual result

Pipenv cannot resolve dependencies with the following error:

verbose output
.venv ❯ pipenv lock --verbose
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead.
Locking [dev-packages] dependencies…
Using pip: -i https://pypi.python.org/simple

                          ROUND 1
Current constraints:

Finding the best candidates:

Finding secondary dependencies:
------------------------------------------------------------
Result of round 1: stable, done

Locking [packages] dependencies…
Using pip: -i https://pypi.python.org/simple

                          ROUND 1
Current constraints:
  django>=2.0
  drf-yasg

Finding the best candidates:
  found candidate django==2.0.4 (constraint was >=2.0)
  found candidate drf-yasg==1.6.1 (constraint was <any>)

Finding secondary dependencies:
  drf-yasg==1.6.1           requires coreapi>=2.3.3, coreapi>=2.3.3, coreschema>=0.0.4, coreschema>=0.0.4, Django<2.0,>=1.11.7; python_version <= "2.7", Django>=1.11.7; python_version >= "3.4", Django>=1.11.7; python_version >= "3.4"; python_version >= "3.4", djangorestframework>=3.7.7, djangorestframework>=3.7.7, future>=0.16.0, future>=0.16.0, inflection>=0.3.1, inflection>=0.3.1, openapi-codec>=1.3.2, openapi-codec>=1.3.2, ruamel.yaml>=0.15.34, ruamel.yaml>=0.15.34, six>=1.10.0, six>=1.10.0, uritemplate>=3.0.0, uritemplate>=3.0.0
  django==2.0.4             requires pytz

New dependencies found in this round:
  adding ['coreapi', '>=2.3.3', '[]']
  adding ['coreschema', '>=0.0.4', '[]']
  adding ['django', '<2.0,>=1.11.7', '[]']
  adding ['djangorestframework', '>=3.7.7', '[]']
  adding ['future', '>=0.16.0', '[]']
  adding ['inflection', '>=0.3.1', '[]']
  adding ['openapi-codec', '>=1.3.2', '[]']
  adding ['pytz', '', '[]']
  adding ['ruamel.yaml', '>=0.15.34', '[]']
  adding ['six', '>=1.10.0', '[]']
  adding ['uritemplate', '>=3.0.0', '[]']
Removed dependencies in this round:
Unsafe dependencies in this round:
------------------------------------------------------------
Result of round 1: not stable

                          ROUND 2
Current constraints:
  coreapi>=2.3.3
  coreschema>=0.0.4
  django<2.0,>=1.11.7,>=2.0
  djangorestframework>=3.7.7
  drf-yasg
  future>=0.16.0
  inflection>=0.3.1
  openapi-codec>=1.3.2
  pytz
  ruamel.yaml>=0.15.34
  six>=1.10.0
  uritemplate>=3.0.0

Finding the best candidates:
  found candidate coreapi==2.3.3 (constraint was >=2.3.3)
  found candidate coreschema==0.0.4 (constraint was >=0.0.4)
Using pip: -i https://pypi.python.org/simple

                          ROUND 1
Current constraints:
  django>=2.0
  drf-yasg

Finding the best candidates:
  found candidate django==2.0.4 (constraint was >=2.0)
  found candidate drf-yasg==1.6.1 (constraint was <any>)

Finding secondary dependencies:
  django==2.0.4             requires pytz
  drf-yasg==1.6.1           requires coreapi>=2.3.3, coreapi>=2.3.3, coreschema>=0.0.4, coreschema>=0.0.4, Django<2.0,>=1.11.7; python_version <= "2.7", Django>=1.11.7; python_version >= "3.4", Django>=1.11.7; python_version >= "3.4"; python_version >= "3.4", djangorestframework>=3.7.7, djangorestframework>=3.7.7, future>=0.16.0, future>=0.16.0, inflection>=0.3.1, inflection>=0.3.1, openapi-codec>=1.3.2, openapi-codec>=1.3.2, ruamel.yaml>=0.15.34, ruamel.yaml>=0.15.34, six>=1.10.0, six>=1.10.0, uritemplate>=3.0.0, uritemplate>=3.0.0

New dependencies found in this round:
  adding ['coreapi', '>=2.3.3', '[]']
  adding ['coreschema', '>=0.0.4', '[]']
  adding ['django', '<2.0,>=1.11.7', '[]']
  adding ['djangorestframework', '>=3.7.7', '[]']
  adding ['future', '>=0.16.0', '[]']
  adding ['inflection', '>=0.3.1', '[]']
  adding ['openapi-codec', '>=1.3.2', '[]']
  adding ['pytz', '', '[]']
  adding ['ruamel.yaml', '>=0.15.34', '[]']
  adding ['six', '>=1.10.0', '[]']
  adding ['uritemplate', '>=3.0.0', '[]']
Removed dependencies in this round:
Unsafe dependencies in this round:
------------------------------------------------------------
Result of round 1: not stable

                          ROUND 2
Current constraints:
  coreapi>=2.3.3
  coreschema>=0.0.4
  django<2.0,>=1.11.7,>=2.0
  djangorestframework>=3.7.7
  drf-yasg
  future>=0.16.0
  inflection>=0.3.1
  openapi-codec>=1.3.2
  pytz
  ruamel.yaml>=0.15.34
  six>=1.10.0
  uritemplate>=3.0.0

Finding the best candidates:
  found candidate coreapi==2.3.3 (constraint was >=2.3.3)
  found candidate coreschema==0.0.4 (constraint was >=0.0.4)

INFO:pip9._vendor.requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): pypi.python.org
INFO:pip9._vendor.requests.packages.urllib3.connectionpool:Resetting dropped connection: pypi.python.org
INFO:pip9._vendor.requests.packages.urllib3.connectionpool:Resetting dropped connection: pypi.python.org
INFO:pip9._vendor.requests.packages.urllib3.connectionpool:Resetting dropped connection: pypi.python.org
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.
Could not find a version that matches django<2.0,>=1.11.7,>=2.0
Tried: 1.1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a1, 1.9b1, 1.9rc1, 1.9rc2, 1.9, 1.9, 1.9.1, 1.9.1, 1.9.2, 1.9.2, 1.9.3, 1.9.3, 1.9.4, 1.9.4, 1.9.5, 1.9.5, 1.9.6, 1.9.6, 1.9.7, 1.9.7, 1.9.8, 1.9.8, 1.9.9, 1.9.9, 1.9.10, 1.9.10, 1.9.11, 1.9.11, 1.9.12, 1.9.12, 1.9.13, 1.9.13, 1.10a1, 1.10a1, 1.10b1, 1.10b1, 1.10rc1, 1.10rc1, 1.10, 1.10, 1.10.1, 1.10.1, 1.10.2, 1.10.2, 1.10.3, 1.10.3, 1.10.4, 1.10.4, 1.10.5, 1.10.5, 1.10.6, 1.10.6, 1.10.7, 1.10.7, 1.10.8, 1.10.8, 1.11a1, 1.11b1, 1.11rc1, 1.11rc1, 1.11, 1.11, 1.11.1, 1.11.1, 1.11.2, 1.11.2, 1.11.3, 1.11.3, 1.11.4, 1.11.4, 1.11.5, 1.11.5, 1.11.6, 1.11.6, 1.11.7, 1.11.7, 1.11.8, 1.11.8, 1.11.9, 1.11.9, 1.11.10, 1.11.10, 1.11.11, 1.11.11, 1.11.12, 1.11.12, 2.0a1, 2.0b1, 2.0rc1, 2.0, 2.0, 2.0.1, 2.0.1, 2.0.2, 2.0.2, 2.0.3, 2.0.3, 2.0.4, 2.0.4
INFO:pip9._vendor.requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): pypi.python.org
INFO:pip9._vendor.requests.packages.urllib3.connectionpool:Resetting dropped connection: pypi.python.org
INFO:pip9._vendor.requests.packages.urllib3.connectionpool:Resetting dropped connection: pypi.python.org
INFO:pip9._vendor.requests.packages.urllib3.connectionpool:Resetting dropped connection: pypi.python.org
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.
Could not find a version that matches django<2.0,>=1.11.7,>=2.0
Tried: 1.1.3, 1.1.4, 1.2, 1.2.1, 1.2.2, 1.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1.9, 1.9.1, 1.9.1, 1.9.2, 1.9.2, 1.9.3, 1.9.3, 1.9.4, 1.9.4, 1.9.5, 1.9.5, 1.9.6, 1.9.6, 1.9.7, 1.9.7, 1.9.8, 1.9.8, 1.9.9, 1.9.9, 1.9.10, 1.9.10, 1.9.11, 1.9.11, 1.9.12, 1.9.12, 1.9.13, 1.9.13, 1.10a1, 1.10a1, 1.10b1, 1.10b1, 1.10rc1, 1.10rc1, 1.10, 1.10, 1.10.1, 1.10.1, 1.10.2, 1.10.2, 1.10.3, 1.10.3, 1.10.4, 1.10.4, 1.10.5, 1.10.5, 1.10.6, 1.10.6, 1.10.7, 1.10.7, 1.10.8, 1.10.8, 1.11a1, 1.11b1, 1.11rc1, 1.11rc1, 1.11, 1.11, 1.11.1, 1.11.1, 1.11.2, 1.11.2, 1.11.3, 1.11.3, 1.11.4, 1.11.4, 1.11.5, 1.11.5, 1.11.6, 1.11.6, 1.11.7, 1.11.7, 1.11.8, 1.11.8, 1.11.9, 1.11.9, 1.11.10, 1.11.10, 1.11.11, 1.11.11, 1.11.12, 1.11.12, 2.0a1, 2.0b1, 2.0rc1, 2.0, 2.0, 2.0.1, 2.0.1, 2.0.2, 2.0.2, 2.0.3, 2.0.3, 2.0.4, 2.0.4
Steps to replicate

Run pipenv lock with the Pipfile provided above.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

So we should allow duplicate entries with different markers in Pipfile too. (which is not supported by my previous commit)

Pipenv uses whichever thing is called python and has precedence unless you tell it specifically which python to create the environment with or you set PIPENV_DEFAULT_PYTHON_VERSION. Use pipenv install --python=3.6 or pipenv install --three or pipenv install --python=/usr/local/bin/python3.6