ISA-tools / isa-api

ISA tools API
https://isa-tools.org
Other
40 stars 37 forks source link

pandas incompatibility (isatools bioconda distribution) #462

Closed vedina closed 1 year ago

vedina commented 1 year ago

The example code https://isa-tools.org/isa-api/content/creation.html throws error using the latest pandas 1.5.0

from isatools.model import *
investigation = Investigation()
investigation.studies.append(Study())  # adds a new default Study object to investigation
---> 28 from pandas.io.parsers import ParserError
     29 from progressbar import ETA, Bar, ProgressBar, SimpleProgress
     31 from isatools import logging as isa_logging

ImportError: cannot import name 'ParserError' from 'pandas.io.parsers' 

in 1.5.0 it should be from pandas.errors import ParserError

https://pandas.pydata.org/docs/reference/api/pandas.errors.ParserError.html

Same error with pandas 1.4.2 in a fresh environment

...

and when trying to install from sources in a new environment it completes with "inconsistent environment " warning and

from isatools.model import *
cannot import name 'isatab' from partially initialized module 'isatools' (most likely due to a circular import)

any advice for a working conda installation? we have other dependencies, relying on pip is a nightmare

terazus commented 1 year ago

Hello @vedina We are preparing an update with bumps to pandas 1.5.0 and numpy 1.23.3. It is available on this branch: https://github.com/ISA-tools/isa-api/tree/DomFixVersions Could you try to install from this branch and tell me if you still have import issues ? If you do, can you please provide more context so I can help resolve the issue (a link to the incriminated file would be ideal) ?

vedina commented 1 year ago

thanks, will try the branch there is no file involved, I was trying the tutorial example code for creating ISA objects

terazus commented 1 year ago

@vedina can you please confirm if there is still a problem (or not) so that I can close the issue :)

kerberizer commented 1 year ago

@terazus Thank you for your patience! I'm afraid @vedina has been quite busy recently, so she asked me to test and reply on her behalf. Yes, the problem with pandas seems to be fixed in DomFixVersions. Really appreciate it!

You are likely aware of this, so mentioning it here just in case: there are import issues with Python 3.10 producing AttributeError: module 'collections' has no attribute 'Mapping' messages, e.g.:

Python 3.10.7 (main, Sep  6 2022, 21:22:27) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from isatools.model import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kerb/dev/isa-api/isatools/__init__.py", line 20, in <module>
    from isatools.convert import (
  File "/home/kerb/dev/isa-api/isatools/convert/mzml2isa.py", line 5, in <module>
    from mzml2isa import __version__
  File "/tmp/isa-api/lib/python3.10/site-packages/mzml2isa/__init__.py", line 42, in <module>
    from . import parsing
  File "/tmp/isa-api/lib/python3.10/site-packages/mzml2isa/parsing.py", line 35, in <module>
    from .isa import ISA_Tab
  File "/tmp/isa-api/lib/python3.10/site-packages/mzml2isa/isa.py", line 31, in <module>
    from .utils import (
  File "/tmp/isa-api/lib/python3.10/site-packages/mzml2isa/utils.py", line 59, in <module>
    class _ChainMap(collections.Mapping):
AttributeError: module 'collections' has no attribute 'Mapping'
>>> from isatools.model import *
>>> investigation = Investigation()
>>> investigation.studies.append(Study())
>>> from isatools import isatab
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kerb/dev/isa-api/isatools/__init__.py", line 20, in <module>
    from isatools.convert import (
  File "/home/kerb/dev/isa-api/isatools/convert/mzml2isa.py", line 5, in <module>
    from mzml2isa import __version__
  File "/home/kerb/.local/lib/python3.10/site-packages/mzml2isa/__init__.py", line 42, in <module>
    from . import parsing
  File "/home/kerb/.local/lib/python3.10/site-packages/mzml2isa/parsing.py", line 35, in <module>
    from .isa import ISA_Tab
  File "/home/kerb/.local/lib/python3.10/site-packages/mzml2isa/isa.py", line 31, in <module>
    from .utils import (
  File "/home/kerb/.local/lib/python3.10/site-packages/mzml2isa/utils.py", line 59, in <module>
    class _ChainMap(collections.Mapping):
AttributeError: module 'collections' has no attribute 'Mapping'
>>> from isatools import isajson
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kerb/dev/isa-api/isatools/__init__.py", line 20, in <module>
    from isatools.convert import (
  File "/home/kerb/dev/isa-api/isatools/convert/mzml2isa.py", line 5, in <module>
    from mzml2isa import __version__
  File "/home/kerb/.local/lib/python3.10/site-packages/mzml2isa/__init__.py", line 42, in <module>
    from . import parsing
  File "/home/kerb/.local/lib/python3.10/site-packages/mzml2isa/parsing.py", line 35, in <module>
    from .isa import ISA_Tab
  File "/home/kerb/.local/lib/python3.10/site-packages/mzml2isa/isa.py", line 31, in <module>
    from .utils import (
  File "/home/kerb/.local/lib/python3.10/site-packages/mzml2isa/utils.py", line 59, in <module>
    class _ChainMap(collections.Mapping):
AttributeError: module 'collections' has no attribute 'Mapping'
>>> quit()
terazus commented 1 year ago

@kerberizer Thank you very much for your feedback. As you can see from the message log, the error originates from mzml2isa which, unfortunatly, is not compatible with Python 3.10. In the meantime, the only solution I found is to locally edit the file mzml2isa utils.py file located in your venv (I see here it would be: "/home/kerb/dev/isa-api/lib/python3.10/site-packages/mzml2isa/utils.py"). At line 59 you can change the _ChainMap inheritance to collections.abc.Mapping, which should fix the issue. image

terazus commented 1 year ago

@kerberizer can you confirm if your problem is solved so i can close the issue ? thx