Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

katdal does not work with python 3.12 #379

Open
spassmoor opened this issue Apr 17, 2024 · 4 comments
Open

katdal does not work with python 3.12 #379

spassmoor opened this issue Apr 17, 2024 · 4 comments
Assignees

Comments

@spassmoor
Copy link
Contributor

spassmoor commented Apr 17, 2024

When opening a rdb file with katdal in python 3.12 I get the error

    173 def load_from_file(self, file: Union[_PathType, BinaryIO]) -> int:
    174     if rdb_reader is None:
--> 175         raise _rdb_reader_import_error   # noqa: F821
    176     with self._write():
    177         return rdb_reader.load_from_file(MemoryCallback(self._data), file)

NameError: name `_rdb_reader_import_error' is not defined

This is caused by katsdptelstate trying to import distutils in a try..except block giving the error ModuleNotFoundError: No module named 'distutils' that is not reported.
distutils was Deprecate in python 3.10 and removed in python 3.12
https://peps.python.org/pep-0632/

I needed to install setuptools to fix this.

@ludwigschwardt
Copy link
Contributor

ludwigschwardt commented Apr 17, 2024

Thanks, Sean. This was already fixed in katsdptelstate 0.13 🙂 Maybe I'll add a minimum requirement in the case of Python 3.12 somewhere...

@spassmoor
Copy link
Contributor Author

In [4]: import katsdptelstate.rdb_reader
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[4], line 1
----> 1 import katsdptelstate.rdb_reader

File ~/ska-sa/katsdptelstate/katsdptelstate/rdb_reader.py:21
     18 import os.path
     19 from typing import Optional, Union, BinaryIO, cast
---> 21 from rdbtools import RdbParser, RdbCallback
     23 from .errors import RdbParseError
     24 from .utils import _PathType

File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/rdbtools/__init__.py:3
      1 from rdbtools.parser import RdbCallback, RdbParser, DebugCallback
      2 from rdbtools.callbacks import JSONCallback, DiffCallback, ProtocolCallback, KeyValsOnlyCallback, KeysOnlyCallback
----> 3 from rdbtools.memprofiler import MemoryCallback, PrintAllKeys, StatsAggregator, PrintJustKeys
      5 __version__ = '0.1.15'
      6 VERSION = tuple(map(int, __version__.split('.')))

File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/rdbtools/memprofiler.py:6
      4 import random
      5 import bisect
----> 6 from distutils.version import StrictVersion
      7 try:
      8     import ujson as json

ModuleNotFoundError: No module named 'distutils'

@bennahugo
Copy link
Contributor

bennahugo commented Apr 17, 2024 via email

@ludwigschwardt
Copy link
Contributor

ludwigschwardt commented Apr 17, 2024

The problem actually lies with rdbtools: a dependency of a dependency of katdal 🤦🏾‍♂️ And rdbtools is also practically dead, with the last update in 2020.

For now this can be worked around by installing setuptools, as Sean said (which is why I missed this - I always install that!).

Longer term I'm looking for a replacement, as documented in SPR1-3073.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants