Skip to content

Run-time warning about import from 'collections'. #19

Open

Description

@kfogel

Got a warning today:

$ python3 -m csv2wiki -c some_config_file some_data.csv 
/usr/lib/python3/dist-packages/html5lib/_trie/_base.py:3: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import Mapping
...
(the run itself went fine and was successful)

I haven't done much research yet, but cursory searching shows others have encountered and easily resolved it:

In our case, I'm not sure exactly where the warning is coming from. As printed, it's in core Python (which is odd, to say the least), and indeed /usr/lib/python3/dist-packages/html5lib/_trie/_base.py does have the line from collections import Mapping.

But this issue might also exist with the Python MediaWiki client library, mwclient, that csv2wiki depends on -- /usr/local/lib/python3.7/dist-packages/mwclient/client.py contains this line: from collections import OrderedDict. The mwclient upstream is here, by the way, and as of right now still has that same import.

Activity

  1. self-assigned this
    on Jul 3, 2019
  2. changed the title [-]Run-time warning coming from html5lib dependency.[/-] [+]Run-time warning about import from 'collections'.[/+] on Jul 3, 2019
  3. kfogel commented on Jul 3, 2019

    @kfogel
    MemberAuthor

    Ah, okay, this is probably about collections vs collections.abc (where "abc" is "Abstract Base Class"). See https://stackoverflow.com/questions/53978542/how-to-use-collections-abc-from-both-python-3-8-and-python-2-7 and https://docs.python.org/3/library/collections.abc.html for more information.

    I'm still puzzled that the html5lib in the core Python 3.7 distribution would be using the obsolete import, but I guess as long as they fix it in 3.8 it doesn't really matter.

  4. rillian commented on Jul 4, 2019

    @rillian

    There may at least be a reprieve while this gets fixed. Python 3.8.0b1 says,

    ${env}/site-packages/jinja2/utils.py:485: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working
        from collections import MutableMapping
    
    
  5. frankduncan commented on Aug 20, 2019

    @frankduncan
    Contributor

    I'm not seeing this, but I am seeing:

    /home/ubuntu/.local/lib/python3.7/site-packages/mwclient/client.py:377: DeprecationWarning: Specifying host as a tuple is deprecated as of mwclient 0.10.0. Please use the new scheme argument instead.
      DeprecationWarning
    

    What version of html5lib do you have?

  6. kfogel commented on Aug 20, 2019

    @kfogel
    MemberAuthor

    @frankduncan, what version of Python were you trying with?

    I'm using Python 3.7.4; I assume that's also the version of html5lib, since it's part of core Python. I'm not seeing the DeprecationWarning you're seeing above. But did you mean to ask about mwclient, rather than html5lib? I'm running mwclient 0.9.3, which I found out like this:

    $ python3
    Python 3.7.4 (default, Jul 11 2019, 10:43:21) 
    [GCC 8.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import mwclient
    >>> print(mwclient.__file__)
    /usr/local/lib/python3.7/dist-packages/mwclient/__init__.py
    >>> 
    

    ...and then I opened up /usr/local/lib/python3.7/dist-packages/mwclient/__init__.py, which had various clues indicating that I should look in /usr/local/lib/python3.7/dist-packages/mwclient/client.py, so I did and that's where I found the __ver__ value.

  7. frankduncan commented on Aug 20, 2019

    @frankduncan
    Contributor

    I'm on mwclient 0.10.0, so maybe you just need to run pip update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions