Skip to content

How to fix "module 'collections' has no attribute 'Iterable'" error #152

Open
@vladmycode

Description

@vladmycode

When trying to retrieve a list of WordPress posts, I got the error module 'collections' has no attribute 'Iterable'. This is because in Python 3.10, the version I was using, the Iterable class has been moved to the collections.abc module.

In order to solve this error, after installing the library with pip install python-wordpress-xmlrpc, open the wordpress_xmlrpc folder (it should be in your virtual environment), then open the file base.py.

Here, you need to make two replacements:

  1. At line 1, replace import collections with import collections.abc
  2. At line 128, replace elif isinstance(raw_result, collections.Iterable): with elif isinstance(raw_result, collections.abc.Iterable):

That should fix the error and allow the script to parse the raw result from the WordPress site.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions