Utility function `_compare_version` does not compare Python version correctly
See original GitHub issue🐛 Bug
To Reproduce
Open a Python environment with Python >= 3.8 Run the following code:
adrian@quantumgrid ~/r/pytorch-lightning (feature/callback-entry-points)> python --version (lightning)
Python 3.8.11
adrian@quantumgrid ~/r/pytorch-lightning (feature/callback-entry-points)> python (lightning)
Python 3.8.11 (default, Aug 6 2021, 08:56:27)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pytorch_lightning.utilities.imports import _compare_version
>>> import operator
>>> _PYTHON_GREATER_EQUAL_3_8_0 = _compare_version("python", operator.ge, "3.8.0")
>>> _PYTHON_GREATER_EQUAL_3_8_0
False
Expected behavior
The above code should return True.
Environment
- CUDA: - GPU: - available: False - version: None
- Packages: - numpy: 1.22.3 - pyTorch_debug: False - pyTorch_version: 1.11.0 - pytorch-lightning: 1.7.0dev - tqdm: 4.64.0
- System: - OS: Darwin - architecture: - 64bit - - processor: i386 - python: 3.8.11 - version: Darwin Kernel Version 19.6.0: Thu Jan 13 01:26:33 PST 2022; root:xnu-6153.141.51~3/RELEASE_X86_64
Additional context
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Utility function `_compare_version` does not compare Python ...
Bug To Reproduce Open a Python environment with Python >= 3.8 Run the ... Utility function _compare_version does not compare Python version correctly...
Read more >How do I compare version numbers in Python? - Stack Overflow
The problem is comparing the version number, which is a string like 2.3.1 . Since I'm comparing strings, 2 sorts above 10, but...
Read more >Compare two Version numbers - GeeksforGeeks
Approach: It is not possible to compare them directly because of the dot, but the versions can compare numeric part wise and then...
Read more >How to compare a program's version in a shell script?
Here I give a solution for comparing Unix Kernel versions. ... With lastversion CLI utility you can compare any arbitrary versions, e.g.:
Read more >How To: Correctly Test for Python's Version — Tab Completion
How To: Correctly Test for Python's Version ... This is because string-wise comparison is not the same as numerical comparison.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi! Is there any solution to this bug now? Except for waiting for version 1.6.2
yes 😃