Hironsan / HateSonar

Hate Speech Detection Library for Python.
https://hatesonar.herokuapp.com/
MIT License
189 stars 37 forks source link

ModuleNotFoundError: No module named 'sklearn.linear_model.logistic' #127

Open f0lie opened 3 years ago

f0lie commented 3 years ago
In [1]: from hatesonar import Sonar

In [2]: sonar = Sonar()
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-b474975b2fe6> in <module>
----> 1 sonar = Sonar()

~/project/.venv/lib/python3.9/site-packages/hatesonar/api.py in __init__(self)
     19         model_file = os.path.join(BASE_DIR, 'model.joblib')
     20         preprocessor_file = os.path.join(BASE_DIR, 'preprocess.joblib')
---> 21         self.estimator = joblib.load(model_file)
     22         self.preprocessor = joblib.load(preprocessor_file)
     23 

~/project/.venv/lib/python3.9/site-packages/joblib/numpy_pickle.py in load(filename, mmap_mode)
    583                     return load_compatibility(fobj)
    584 
--> 585                 obj = _unpickle(fobj, filename, mmap_mode)
    586     return obj

~/project/.venv/lib/python3.9/site-packages/joblib/numpy_pickle.py in _unpickle(fobj, filename, mmap_mode)
    502     obj = None
    503     try:
--> 504         obj = unpickler.load()
    505         if unpickler.compat_mode:
    506             warnings.warn("The file '%s' has been generated with a "

/usr/lib/python3.9/pickle.py in load(self)
   1210                     raise EOFError
   1211                 assert isinstance(key, bytes_types)
-> 1212                 dispatch[key[0]](self)
   1213         except _Stop as stopinst:
   1214             return stopinst.value

/usr/lib/python3.9/pickle.py in load_global(self)
   1526         module = self.readline()[:-1].decode("utf-8")
   1527         name = self.readline()[:-1].decode("utf-8")
-> 1528         klass = self.find_class(module, name)
   1529         self.append(klass)
   1530     dispatch[GLOBAL[0]] = load_global

/usr/lib/python3.9/pickle.py in find_class(self, module, name)
   1577             elif module in _compat_pickle.IMPORT_MAPPING:
   1578                 module = _compat_pickle.IMPORT_MAPPING[module]
-> 1579         __import__(module, level=0)
   1580         if self.proto >= 4:
   1581             return _getattribute(sys.modules[module], name)[0]

ModuleNotFoundError: No module named 'sklearn.linear_model.logistic'
Package         Version
--------------- ---------
blis            0.7.4
catalogue       2.0.3
certifi         2020.12.5
chardet         4.0.0
click           7.1.2
cymem           2.0.5
hatesonar       0.0.7
idna            2.10
Jinja2          2.11.3
joblib          1.0.1
MarkupSafe      1.1.1
murmurhash      1.0.5
nltk            3.6.2
numpy           1.20.2
packaging       20.9
pandas          1.2.4
pathy           0.4.0
pip             21.0.1
preshed         3.0.5
psaw            0.1.0
pydantic        1.7.3
pyparsing       2.4.7
python-dateutil 2.8.1
pytz            2021.1
regex           2021.4.4
requests        2.25.1
scikit-learn    0.24.1
scipy           1.6.2
setuptools      56.0.0
six             1.15.0
smart-open      3.0.0
spacy           3.0.5
spacy-legacy    3.0.2
spacytextblob   3.0
srsly           2.4.1
textblob        0.15.3
thinc           8.0.3
threadpoolctl   2.1.0
tqdm            4.60.0
typer           0.3.2
urllib3         1.26.4
wasabi          0.8.2
wheel           0.36.2

This looks like it's related to scikit-learn being 24 and the pickled files are from scikit-learn 23.2 according to the repo readme. I tried to install scikit-learn 23 but that failed and I ended up in build hell with numpy and arch linux.

k3KAW8Pnf7mkmdSMPHz27 commented 2 years ago

Loosely refs. #157 ?

k3KAW8Pnf7mkmdSMPHz27 commented 2 years ago

Side-note, if someone ends up here based on the 0.0.7 pip version, you probably need scikit-learn 0.22.2.post1

sadmoody commented 1 year ago

You'll also need numpy<1.20 (if you set it to 1.19.5 you should be good)