You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting some Attribute Errors when making shifts if using a newer version of python.
File "/Users/michael/projects/data-mountain-query/data_mountain_query/sentiment_plot.py", line 378, in general_sentiment_shift
sentiment_shift = sh.WeightedAvgShift(type2freq_1=type2freq_1,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/michael/miniconda3/envs/data-mountain-query/lib/python3.11/site-packages/shifterator/shifts.py", line 59, in __init__
super().__init__(
File "/Users/michael/miniconda3/envs/data-mountain-query/lib/python3.11/site-packages/shifterator/shifterator.py", line 72, in __init__
self.type2score_1, lex_ref = helper.get_score_dictionary(type2score_1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/michael/miniconda3/envs/data-mountain-query/lib/python3.11/site-packages/shifterator/helper.py", line 156, in get_score_dictionary
if isinstance(scores, collections.Mapping):
^^^^^^^^^^^^^^^^^^^
AttributeError: module 'collections' has no attribute 'Mapping'
It's an easy fix, just need to change line 156 in helper.py from
Actually, if you want to make it backward compatible and not deal with different versions of shifterator for different versions of python, I would add something like this:
try:
from collections.abc import Mapping
except ImportError:
from collections import Mapping
in the imports and then just edit to have Mapping on line 156
Getting some Attribute Errors when making shifts if using a newer version of python.
It's an easy fix, just need to change line 156 in helper.py from
to
see this stack overflow post for more: https://stackoverflow.com/questions/69381312/in-vs-code-importerror-cannot-import-name-mapping-from-collections
The text was updated successfully, but these errors were encountered: