Import pandas error after upgrading version. python3.8 problem?

After upgrading pandas version, I cannot import pandas anymore. The error traces to module ‘typing’:
AttributeError: module 'typing' has no attribute '_ClassVar'

After diving into stackoverflow. this seems to be a problem with ‘typing’ not being compatible with newer python versions: python - AttributeError: type object 'Callable' has no attribute '_abc_registry' - Stack Overflow

Can anyone please advice me on how to fix this? I am thinking downgrading to python3.6 or 3.7 is the solution here, anybody knows how?

Thanks!
Best,
Yosse

Hello Yosse,

We got a report of this problem by another user, he opened this ticket:

https://sft.its.cern.ch/jira/browse/SPI-1806

There is a proposed workaround that you can try.

1 Like

Thanks for the pointer! I can confirm the workaround works.
I sure hope the bug gets resolved soon.

Hi again Enric,

Unfortunately this workaround does not work in swan-k8s. It returns this error:
Traceback (most recent call last):

  File "/cvmfs/sft.cern.ch/lcg/views/LCG_99cuda/x86_64-centos7-gcc8-opt/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3296, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-6-027d28fa2663>", line 3, in <module>
    import pandas as pd

  File "/eos/user/s/sandrean/.local/lib/python3.7/site-packages/pandas/__init__.py", line 51, in <module>
    from pandas.core.api import (

  File "/eos/user/s/sandrean/.local/lib/python3.7/site-packages/pandas/core/api.py", line 31, in <module>
    from pandas.core.groupby import Grouper, NamedAgg

  File "/eos/user/s/sandrean/.local/lib/python3.7/site-packages/pandas/core/groupby/__init__.py", line 1, in <module>
    from pandas.core.groupby.generic import DataFrameGroupBy, NamedAgg, SeriesGroupBy

  File "/eos/user/s/sandrean/.local/lib/python3.7/site-packages/pandas/core/groupby/generic.py", line 65, in <module>
    from pandas.core.frame import DataFrame

  File "/eos/user/s/sandrean/.local/lib/python3.7/site-packages/pandas/core/frame.py", line 119, in <module>
    from pandas.core import algorithms, common as com, generic, nanops, ops

  File "/eos/user/s/sandrean/.local/lib/python3.7/site-packages/pandas/core/generic.py", line 112, in <module>
    from pandas.io.formats import format as fmt

  File "/eos/user/s/sandrean/.local/lib/python3.7/site-packages/pandas/io/formats/format.py", line 77, in <module>
    from pandas.io.common import stringify_path

  File "/eos/user/s/sandrean/.local/lib/python3.7/site-packages/pandas/io/common.py", line 6, in <module>
    import dataclasses

  File "/cvmfs/sft.cern.ch/lcg/views/LCG_99/x86_64-centos7-gcc8-opt/lib/python3.8/dataclasses.py", line 996
    def dataclass(cls=None, /, *, init=True, repr=True, eq=True, order=False,
                            ^
SyntaxError: invalid syntax

I notice k8s uses python 3.7. Is there any solution for this particular case?

Hello,

In the SPI ticket above it says dataclasses were added as built-in in Python3.7, so perhaps you need to change to this path:

/cvmfs/sft.cern.ch/lcg/views/LCG_99cuda/x86_64-centos7-gcc8-opt/lib/python3.7/

which is the corresponding one in the CUDA stack that you are using.

Could you please anyway report this issue with the CUDA stack too in the SPI ticket I referenced above?

We just removed the non standard lib dataclasses.py from all the LCG_99 and LCG_99cuda views on cvmfs, it will probably take a couple hours to propagate.

1 Like

Thank you for the update Andre!

Thanks! I can confirm now import pandas work as per normal.