2

Is there a way to specify minimum python version requirement for my script ? For example my script requires python 3.6+ because it uses f-string. I have test my script under 3.7, 3.8, 3.9, they all work.

But since pipfile doesn't support minimum version, refer to pipenv specify minimum version of python in pipfile? and this open issue https://github.com/pypa/pipfile/issues/87

So is there a way to do that ? Now I just write it in readme.

--- update ---

https://github.com/pypa/pipenv/issues/2683 indeed said

Note that the python_version key is optional. You can always remove it if it causes problems, and document the version requirements otherwise (i.e. in the README).

0

1 Answer 1

1

Check this post. This may do what you require:

#!/usr/bin/env python
import sys

if sys.version_info[0] != 3 or sys.version_info[1] < 6:
    print("This script requires Python version 3.6")
    sys.exit(1)

# rest of script, including real initial imports, here
Sign up to request clarification or add additional context in comments.

4 Comments

thanks, so that requires adding version check in my python script.
I don't fully understand your comment. Is this a question or a statement?
@Qiulang: Yes, that is what it means. However you do it will involve writing so code yourself.
@Albin sorry I meant a statement. I need to add the minimum version check in my script.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.