46

Is there a way in pipenv to specify the minimum version of python in the Pipfile?

Would something like this work?

[requires]
python_version = ">=python 3.5"
Rob Bednark
  • 25,981
  • 23
  • 80
  • 125
Jasonca1
  • 4,848
  • 6
  • 25
  • 42
  • 7
    it seems they just support hard version pins for Python. There is an [issue on Github](https://github.com/pypa/pipfile/issues/87) – lmiguelvargasf Jul 24 '18 at 07:07
  • Thanks @lmiguelvargasf. I appreciate the prompt response. I hope that they will implement support for this feature down the road. – Jasonca1 Jul 24 '18 at 11:07
  • I agree with you. It would be awesome if they provide this feature. – lmiguelvargasf Jul 24 '18 at 14:35
  • 7
    To follow up on this, the devs have [explicitly](https://github.com/pypa/pipenv/issues/1050#issuecomment-346203646) said that they will not be adding this feature - even though it puzzles quite a lot of users. [The issue.](https://github.com/pypa/pipenv/issues/1050) – Bram Vanroy Dec 19 '18 at 14:00
  • I agree @BramVanroy, I think this feature would be very handy. Hopefully the devs, given enough pressure from the community, change their mind on this and implement it. I would love to see pipenv ship with future versions of python and become the defacto standard for managing virtualenvs in the python language. – Jasonca1 Dec 19 '18 at 14:29

2 Answers2

42

No, pipenv does not support this. Per pipenv issue 1050 feature request, the pipenv authors have explicitly chosen not to implement it.

Note that you can specify:

 python_version = "3"

to allow any version of Python 3. Not exactly what you asked for, but it might be sufficient for some projects.

Rob Bednark
  • 25,981
  • 23
  • 80
  • 125
  • 1
    for any version 3 of python, this is what worked for me python_version = "3" – Jean-Frederic PLANTE Dec 31 '20 at 02:07
  • I think this is the correct answer. But I'd like to note that I've found that using "3" means that `pipenv check` will always fail. This is because 3 != 3.8 or whatever version is used. I presume that is in the backlog of things to fix. – John Nov 09 '21 at 21:58
  • 1
    This does not seem to with with version 2022.12.19 anymore. I get "Specifier python_version does not match 3 (3.8)." when running "pipenv check". – ericbn Jan 05 '23 at 15:19
1

As other answers explain, this is not supported in Pipenv and is never going to be supported by decision of the maintainers.

Instead, you can use Poetry, which does not have such an attitude and does not have any problem with specifying an arbitrary version range for supported Python versions.

Resigned June 2023
  • 4,638
  • 3
  • 38
  • 49