ros / urdf_parser_py

Standalone URDF parser for Python.
83 stars 48 forks source link

Python 3.10 compatibility: `collections.Iterable` cannot be imported #72

Closed sdahdah closed 2 years ago

sdahdah commented 2 years ago

Issue

On Python 3.10.2, when calling print() on a joint or other object, I get the error:

AttributeError: module 'collections' has no attribute 'Iterable'

I assume this is from line 72 of urdf_parser_py/src/urdf_parser_py/xml_reflection/basics.py:

    elif isinstance(obj, collections.Iterable):
        out = [to_yaml(item) for item in obj]
    else:

I believe it should be Iterable should be imported from collections.abc now instead of directly from collections.

A related issue in another library: https://github.com/nerdocs/pydifact/issues/46

Code to reproduce:

import urdf_parser_py.urdf

robot = urdf_parser_py.urdf.URDF.from_xml_file('./my_urdf.urdf')
for joint in robot.joints:
    print(joint)
clalancette commented 2 years ago

See #73 for a fix.

sdahdah commented 2 years ago

Thanks a bunch!

anix-anirban commented 2 years ago

cerebro.optstrategy is throwing the error:

Traceback (most recent call last): File "c:\Users\anirb\Trading\.backtrader\trader.py", line 18, in <module> strats = cerebro.optstrategy( File "C:\Users\anirb\Trading\.backtrader\lib\site-packages\backtrader\cerebro.py", line 893, in optstrategy vals = self.iterize(kwargs.values()) File "C:\Users\anirb\Trading\.backtrader\lib\site-packages\backtrader\cerebro.py", line 333, in iterize elif not isinstance(elem, collections.Iterable): AttributeError: module 'collections' has no attribute 'Iterable'

How can I resolve this?

I am on Python 3.10 which is probably creating the issue. Is there any quick fix?

Thanks in advance

clalancette commented 2 years ago

This was fixed long ago in #73, so closing this out.

@anix-anirban Please don't ask for help for unrelated packages. I don't know what cerebro is, but the best thing to do is open an issue over there.