CamDavidsonPilon / lifelines

Survival analysis in Python
lifelines.readthedocs.org
MIT License
2.32k stars 551 forks source link

`import lifelines` errors with `SyntaxError` in Python 3.7 #1517

Closed DrShushen closed 1 year ago

DrShushen commented 1 year ago

There appears to be a bug in lifelines 0.27.5 with Python 3.7.

To replicate:

  1. Have an environment with Python 3.7, e.g. conda create -n env_lifelines python=3.7
  2. Install lifelines 0.27.5, e.g. pip install "lifelines==0.27.5"
  3. In Python run import lifelines

You get SyntaxError as below - looks like an fstring issue:

import lifelines
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/<...>/python3.7/site-packages/lifelines/__init__.py", line 5, in <module>
    from lifelines.fitters.weibull_fitter import WeibullFitter
  File "<fstring>", line 1
    (minimum_results=)
                    ^
SyntaxError: invalid syntax

Note that:

CamDavidsonPilon commented 1 year ago

Oh shoot, that feature is py3.8+ only. I'll update with a fix!

CamDavidsonPilon commented 1 year ago

0.27.6 is released now on PyPI

tztsai commented 1 year ago

Yes this feature f"{minimum_results=}" is only supported by py3.8+.