5

I have just installed Python 3.7 on my Mac (High Sierra v 10.13.2). When I run code that uses sklearn I get the following error message:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sklearn/feature_extraction/text.py:17: 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, defaultdict

Does anybody know how to eliminate this deprecation warning? I understand that I can ask Python not to show deprecation warnings. I would like to remove the cause of the deprecation warning rather than just remove the warning itself. What I would like to understand is if I can change SKLearn's use of collections or is that something I will need to wait for sklearn to accomplish?

Bill Orton
  • 135
  • 1
  • 6
  • 11
  • 2
    Wait for the sklearn project to update their codebase? You can tell Python to not show deprecation warnings otherwise, see the duplicate. – Martijn Pieters Aug 27 '18 at 13:55
  • 2
    Obviously noone ever told the python developers, that deprecating features in a minor version is a nono. – Bachsau Nov 29 '18 at 14:38
  • 1
    @MartijnPieters Is this really a duplicate - in the sense that how /why should that warning be expected in the first place? It is v surprising to be seeing it coming from key python modules. – WestCoastProjects May 18 '19 at 12:39
  • @javadba the core python module is warning you that *your code* is using something deprecated. See the other post on how to silence that or how to turn the warning into an exception so you can diagnose how your code triggers it. – Martijn Pieters May 18 '19 at 13:02
  • Not sure since when, but this warning is not about my code. I can trigger it by doing import collections; a = collections.Mapping(). The warning does not explain how I should use that class without getting the warning. Perhaps they need to fix it before the next release? This doesn't seem to be my problem, so I should not see this warning. – Bas Wijnen Apr 20 '20 at 08:39
  • Ok, I found the problem; the warning is not very clear on this. Classes like Mapping are "abstract base classes". They have moved from collections to collections.abc. So now it's called collections.abc.Mapping. If you import that, everything works. – Bas Wijnen Apr 20 '20 at 08:47

0 Answers0