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

Issue with joblib #15

Open
o2ba opened this issue May 20, 2020 · 14 comments
Open

Issue with joblib #15

o2ba opened this issue May 20, 2020 · 14 comments

Comments

@o2ba
Copy link

o2ba commented May 20, 2020

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?

@o2ba
Copy link
Author

o2ba commented May 20, 2020

Fix for anyone wondering: Downgrade your scikit-learn to 0.20.2 to fix this issue.

@MebinAbraham
Copy link

scikit-learn 0.22.2.post1 is what worked for me.

@workaddiction
Copy link

Whenever I try to use scikit-learn 0.20.2, it gets stuck at building when running the setup.py
(Python 3.8)

@ilhan-mstf
Copy link

ilhan-mstf commented Jun 11, 2020

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?

@ccombsnbcu
Copy link

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

@rscarrera27
Copy link

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 .

@afghani-iitkgp
Copy link

afghani-iitkgp commented Aug 3, 2020

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 ??

@Echooff3
Copy link

Echooff3 commented Aug 7, 2020

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)

@astherath
Copy link

Getting same error as @Echooff3 on python37 and scikit-learn==0.20.2

@bhagyesh-p
Copy link

I dont think the downgrade helps. Getting the same error

@az0
Copy link

az0 commented Sep 7, 2020

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

@hoai97nam
Copy link

scikit-learn 0.22.2.post1 is what worked for me.

it worked for me too, many thanks

@alexpovel
Copy link

alexpovel commented Nov 3, 2020

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.

@xhulianoThe1
Copy link

xhulianoThe1 commented Mar 14, 2021

Found this as an alternative:

https://pypi.org/project/alt-profanity-check/

Worked for me with Python 3.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests