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

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

Open
kfogel opened this issue Jul 3, 2019 · 5 comments
Open

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

kfogel opened this issue Jul 3, 2019 · 5 comments
Assignees
Labels

Comments

@kfogel
Copy link
Member

kfogel commented Jul 3, 2019

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.

@kfogel kfogel added the bug label Jul 3, 2019
@kfogel kfogel self-assigned this Jul 3, 2019
@kfogel kfogel changed the title Run-time warning coming from html5lib dependency. Run-time warning about import from 'collections'. Jul 3, 2019
@kfogel
Copy link
Member Author

kfogel commented Jul 3, 2019

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.

@rillian
Copy link

rillian commented Jul 4, 2019

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

@frankduncan
Copy link
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?

@kfogel
Copy link
Member Author

kfogel commented Aug 20, 2019

@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.

@frankduncan
Copy link
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
Labels
Projects
None yet
Development

No branches or pull requests

3 participants