Skip to content

Not working with python version 3.9-dev #13347

@martinosorb

Description

@martinosorb

🐛 Bug

Pytorch lightning fails to import on python 3.9-dev (3.9.12+) due to the use of Version on an inappropriately formatted version string:

File ~/.pyenv/versions/3.9-dev/lib/python3.9/site-packages/pytorch_lightning/utilities/imports.py:90, in <module>
     88 _IS_WINDOWS = platform.system() == "Windows"
     89 _IS_INTERACTIVE = hasattr(sys, "ps1")  # https://stackoverflow.com/a/64523765
---> 90 _PYTHON_GREATER_EQUAL_3_8_0 = Version(platform.python_version()) >= Version("3.8.0")
     91 _TORCH_GREATER_EQUAL_1_8_1 = _compare_version("torch", operator.ge, "1.8.1")
     92 _TORCH_GREATER_EQUAL_1_9 = _compare_version("torch", operator.ge, "1.9.0")

...

InvalidVersion: Invalid version: '3.9.12+'

To Reproduce

import pytorch_lightning on my setup with python 3.9-dev.

Expected behavior

The version check should not be based on platform.python_version(), as this is a string and apparently it's not PEP 440-compliant. There are better ways to get python version in a machine-readable way.

Environment

  • CUDA:
    • GPU:
      • NVIDIA GeForce RTX 3070 Laptop GPU
    • available: True
    • version: 11.3
  • Packages:
    • numpy: 1.21.6
    • pyTorch_debug: False
    • pyTorch_version: 1.12.0.dev20220517+cu113
    • tqdm: 4.64.0
    • pytorch-lightning 1.6.4
  • System:
    • OS: Linux
    • architecture:
      • 64bit
      • ELF
    • processor: x86_64
    • python: 3.9.12+
    • version: fixed clip grad warning #42-Ubuntu SMP Thu Jun 9 23:42:32 UTC 2022
      of torch.__config__.show():

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions