profanity-check
profanity-check copied to clipboard
Issue with joblib
Traceback (most recent call last):
File "C:/Users/conta/PycharmProjects/Discord/bot.py", line 11, in <module>
from profanity_check import predict, predict_prob
File "C:\Users\conta\anaconda3\envs\Discordbot\lib\site-packages\profanity_check\__init__.py", line 1, in <module>
from .profanity_check import predict, predict_prob
File "C:\Users\conta\anaconda3\envs\Discordbot\lib\site-packages\profanity_check\profanity_check.py", line 3, in <module>
from sklearn.externals import joblib
ImportError: cannot import name 'joblib' from 'sklearn.externals' (C:\Users\conta\anaconda3\envs\Discordbot\lib\site-packages\sklearn\externals\__init__.py)
I've been trying to fix this error for a bit now, tried up & downgrading. Probably a case of dependency hell, has anyone else experienced this before?
Fix for anyone wondering: Downgrade your scikit-learn to 0.20.2 to fix this issue.
scikit-learn 0.22.2.post1
is what worked for me.
Whenever I try to use scikit-learn 0.20.2, it gets stuck at building when running the setup.py (Python 3.8)
How can I run it on my local to fix the issue? I cloned the repo on my local, but I don't know what to do next. Can you help me?
How can I run it on my local to fix the issue? I cloned the repo on my local, but I don't know what to do next. Can you help me?
Assuming you're using pip3
(pip may work as well):
pip3 uninstall scikit-learn
pip3 install scikit-learn==0.20.2
Fix for anyone wondering: Downgrade your scikit-learn to 0.20.2 to fix this issue.
Not working for python3.8. py3.8 requires sklearn >= 0.22 .
joblib==0.14.1 scikit-learn==0.20.2
>>> vectorizer = joblib.load(pkg_resources.resource_filename('profanity_check', 'data/vectorizer.joblib'))
>>> model = joblib.load(pkg_resources.resource_filename('profanity_check', 'data/model.joblib'))
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/home/user/anaconda3/envs/project/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 605, in load
obj = _unpickle(fobj, filename, mmap_mode)
File "/home/user/anaconda3/envs/project/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 529, in _unpickle
obj = unpickler.load()
File "/home/user/anaconda3/envs/project/lib/python3.7/pickle.py", line 1088, in load
dispatch[key[0]](self)
KeyError: 0
While loading model KeyError pops.
What version of joblib is required to load the model ??
Running Python 3.8.5 (OSX) Downgraded scikit-learn to 0.22.2 I'm getting a different error
>>> from profanity_check import predict
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/profanity_check/__init__.py", line 1, in <module>
from .profanity_check import predict, predict_prob
File "/usr/local/lib/python3.8/site-packages/profanity_check/profanity_check.py", line 3, in <module>
from sklearn.externals import joblib
File "/usr/local/lib/python3.8/site-packages/sklearn/__init__.py", line 64, in <module>
from .base import clone
File "/usr/local/lib/python3.8/site-packages/sklearn/base.py", line 13, in <module>
from .utils.fixes import signature
File "/usr/local/lib/python3.8/site-packages/sklearn/utils/__init__.py", line 14, in <module>
from . import _joblib
File "/usr/local/lib/python3.8/site-packages/sklearn/utils/_joblib.py", line 22, in <module>
from ..externals import joblib
File "/usr/local/lib/python3.8/site-packages/sklearn/externals/joblib/__init__.py", line 119, in <module>
from .parallel import Parallel
File "/usr/local/lib/python3.8/site-packages/sklearn/externals/joblib/parallel.py", line 28, in <module>
from ._parallel_backends import (FallbackToBackend, MultiprocessingBackend,
File "/usr/local/lib/python3.8/site-packages/sklearn/externals/joblib/_parallel_backends.py", line 22, in <module>
from .executor import get_memmapping_executor
File "/usr/local/lib/python3.8/site-packages/sklearn/externals/joblib/executor.py", line 14, in <module>
from .externals.loky.reusable_executor import get_reusable_executor
File "/usr/local/lib/python3.8/site-packages/sklearn/externals/joblib/externals/loky/__init__.py", line 12, in <module>
from .backend.reduction import set_loky_pickler
File "/usr/local/lib/python3.8/site-packages/sklearn/externals/joblib/externals/loky/backend/reduction.py", line 125, in <module>
from sklearn.externals.joblib.externals import cloudpickle # noqa: F401
File "/usr/local/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/__init__.py", line 3, in <module>
from .cloudpickle import *
File "/usr/local/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py", line 167, in <module>
_cell_set_template_code = _make_cell_set_template_code()
File "/usr/local/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py", line 148, in _make_cell_set_template_code
return types.CodeType(
TypeError: an integer is required (got type bytes)
Getting same error as @Echooff3 on python37 and scikit-learn==0.20.2
I dont think the downgrade helps. Getting the same error
A few months ago, I had this all working, but now I get the same error.
Ubuntu 20.04 Python 3.8.2 webvtt-py==0.4.5 scikit-learn==0.20.2 joblib==0.16.0
File "/tmp/youtubeget/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py", line 148, in _make_cell_set_template_code
return types.CodeType(
TypeError: an integer is required (got type bytes)
The problem is compatibility with Python 3.8. I tried Ubuntu 20.04's Python 2.7, but another module I need requires Python 3. Then I used a PPA to install Python 3.7, and it all works. Here's a script
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.7 python3.7-venv
VENVDIR=/tmp/venv/youtubeget
rm -rf $VENVDIR
python3.7 -m venv $VENVDIR
source $VENVDIR/bin/activate
python -m pip install profanity_check scikit-learn==0.20.2 joblib
scikit-learn
0.22.2.post1
is what worked for me.
it worked for me too, many thanks
The solution to downgrade (@az0 ) worked for me, too. Using poetry
, the relevant entry looks like (this installs joblib
as a dependency automatically):
[tool.poetry.dependencies]
python = "3.7.9"
profanity-check = "1.0.3"
scikit-learn = "0.20.2"
However, I set this up using pyenv
, without altering the system python. This worked quite well after initial confusions. It should work and integrate well with poetry
, see here or here.
Found this as an alternative:
https://pypi.org/project/alt-profanity-check/
Worked for me with Python 3.8