question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

cc @borda @akihironitta

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
HeyQXXcommented, Apr 19, 2022

Hi! Is there any solution to this bug now? Except for waiting for version 1.6.2

0reactions
Bordacommented, Apr 19, 2022

Except for waiting for version 1.6.2

yes 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found