e2nIEE / pandapower

Convenient Power System Modelling and Analysis based on PYPOWER and pandas
https://www.pandapower.org
Other
848 stars 478 forks source link

[bug] Invalid syntax in python 3.7 and pandapower 2.12 #1985

Closed BDonnot closed 1 year ago

BDonnot commented 1 year ago

Issue Report Checklist

Problem Description

When installed from scratch in python 3.7 (pandapower 2.12) i got the following error:

from pandapower.toolbox.result_info import *

This raises the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".local/lib/python3.7/site-packages/pandapower/__init__.py", line 14, in <module>
    from pandapower.toolbox import *  # to be removed -> in future via package namespace available
  File ".local/lib/python3.7/site-packages/pandapower/toolbox/__init__.py", line 2, in <module>
    from pandapower.toolbox.result_info import *
  File "<fstring>", line 1
    (element_type=)
                 ^
SyntaxError: invalid syntax

What steps reproduce the problem?

  1. install python 3.7 (3.7.16 for me but I guess any version works)
  2. install pandapower: python3.7 -m pip install --upgrade pandapower
  3. run python3.7 -c "from pandapower.toolbox.result_info import *"

What is the expected output? What do you see instead?

Paste Traceback/Error Below (if applicable)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".local/lib/python3.7/site-packages/pandapower/__init__.py", line 14, in <module>
    from pandapower.toolbox import *  # to be removed -> in future via package namespace available
  File ".local/lib/python3.7/site-packages/pandapower/toolbox/__init__.py", line 2, in <module>
    from pandapower.toolbox.result_info import *
  File "<fstring>", line 1
    (element_type=)
                 ^
SyntaxError: invalid syntax

Versions

Above informations are irrelevant for the bug, this is a problem with the fstring not support the syntax f"{var = }" in python 3.7 (introduced apparently in python 3.8) , as shown in this super simple example:

 > python3.7 -c "a = 2; print(f'{a = }')"
  File "<fstring>", line 1
    (a = )
       ^
SyntaxError: invalid syntax

I can find them for you if you want

Labels (if access available)

SteffenMeinecke commented 1 year ago

python 3.7 support has been dropped with the latest version since its life is going to end soon. Please update your python installation.

BDonnot commented 1 year ago

Hello,

This error arises in a unit test script. I'll make sure not to install latest version of pandapower for older python versions. I totally understand you drop support for 3.7 this makes total sense.

A better solution would be not to release new version of pandapower on pypi for python 3.7 I think.

Indeed, as of now trying to install it on python 3.7 is impossible due to above-mentioned error.

SteffenMeinecke commented 1 year ago

Sorry for complications but why is it so that a new pp version appears for py37? At Pypi, it is clearly released for >py38... Pypi_screenshot_of_pp_2 12 0

BDonnot commented 1 year ago

Hello,

I don't know the why but I assure you that, when you run python 3.7 (I installed a clean version locally on purpose) and try to install pandapower, it finds (and install) a non working pandapower version (2.12 in this case) and not 2.11 (which is the latest supported as far as I understand)

You can do the set in a virtual machine, in a docker container or in your computer.

Benjamin

BDonnot commented 1 year ago

I create a venv for python3.7 from scratch, installed pandapower and you can see it installs pandapower 2.12 which should not happen:

image

To reproduce:

python3.7 -m virtualenv venv_37
source venv_37/bin/activate
pip install pandapower --no-cache-dir  # I added this option to prevent pip from using the cache (pandapower 2.12 could be in the cache for other python version)
python -c "import pandapower as pp; print(pp.__version__)"
SteffenMeinecke commented 1 year ago

should be fixed now. please reopen if some problems occur.