vzhou842 / profanity-check

A fast, robust Python library to check for offensive language in strings.
https://pypi.org/project/profanity-check
MIT License
612 stars 113 forks source link

ImportError: cannot import name 'joblib' from 'sklearn.externals' #28

Open Darkempire78 opened 3 years ago

Darkempire78 commented 3 years ago

I'm tying to test the module but it is do not works :/

image

preetshah21699 commented 3 years ago

The same error occurs with me as well. It didn't occur earlier, like 5-10 days back. However, it appeared today, suddenly.

Darkempire78 commented 3 years ago

@preetshah21699 Currently the module is not updated... It's very sad, but a new version is available here : https://github.com/dimitrismistriotis/profanity-check (i use that for solve the issue, very well)

dimitrismistriotis commented 3 years ago

@Darkempire78

How we feel about this right now (me + @koti the other contributor)

image

nitin-bommi commented 3 years ago

@preetshah21699 Currently the module is not updated... It's very sad, but a new version is available here : https://github.com/dimitrismistriotis/profanity-check (i use that for solve the issue, very well)

How to install this?

dimitrismistriotis commented 3 years ago

@Nitin1901 :drum: :drum: :drum: ... and: https://pypi.org/project/alt-profanity-check/ Drop in replacement which we released just yesterday.

For the immediate forked repository, It is easy to install as is with something like this in your requirements.txt:

-e git+https://github.com/dimitrismistriotis/profanity-check.git#egg=profanity-check
preetshah21699 commented 3 years ago

If we have a solution, why isn't it published on pypi.org?

menkotoglou commented 3 years ago

@preetshah21699 as stated on @dimitrismistriotis comment, the solution is published here: https://pypi.org/project/alt-profanity-check/

preetshah21699 commented 3 years ago

@koti Yes, I saw it. But it just doesn't make sense to have the same thing under a completely different name. But anyway, thanks.

dimitrismistriotis commented 3 years ago

If we have a solution, why isn't it published on pypi.org?

A few things here:

But it just doesn't make sense to have the same thing under a completely different name.

We cannot merge on this repository and even if we could this might break work of people who depend on it as-is.

About "same thing under a completely different name": it is called forking and there are TONS of forks around, and the name is deliberately not "completely" different, we had the same name prefixed with "alt-".

But anyway, thanks.

Welcome. I guess while writing this that I probably overreacted, it took us some hours and learning to do this.

nonbeing commented 3 years ago

Thanks @dimitrismistriotis, @koti and all the other contributors for your work, really appreciate that you are still updating and keeping this work alive 👍

menkotoglou commented 3 years ago

Hey everyone, we just wanted to update you on this and announce that @dimitrismistriotis and I created an API for the library. In fact, it is a wrap of the alt-profanity-check package you can find here: https://pypi.org/project/alt-profanity-check/.

You can find the API here: https://rapidapi.com/mistriotis-mistriotis-default/api/profanity-check1.

Feedback, questions and subscriptions are highly appreciated. Please feel free to reach out to both of us for any questions or feedback about the API.

CrashtestEnigma commented 3 years ago

Hey everyone, we just wanted to update you on this and announce that @dimitrismistriotis and I created an API for the library. In fact, it is a wrap of the alt-profanity-check package you can find here: https://pypi.org/project/alt-profanity-check/.

You can find the API here: https://rapidapi.com/mistriotis-mistriotis-default/api/profanity-check1.

Feedback, questions and subscriptions are highly appreciated. Please feel free to reach out to both of us for any questions or feedback about the API.

ah hello, when i try to check if a string is offensive it prints nothings and ends. the exit code is 0.

menkotoglou commented 3 years ago

@CrashtestEnigma, we need more information on this. What's your input? The library returns 0 for "Not offensive" and 1 for "offensive". How did you try to check the string? Did you use the API we created?

CrashtestEnigma commented 3 years ago

@koti Yes, I used the API you guys created. I tried to test it exactly how the documentation usage told me to. I used the predict function to test if "Hello" was offensive. My exact code was:

from profanity_check import predict

predict(['Hello'])

The code snippet returns nothing. Neither 1 nor 0. The exit code is 0. I'm new to programming in general so I might be making a mistake. If you need any more information I would be glad to tell!

BradKML commented 3 years ago

@CrashtestEnigma That is a very beginner mistake, as this is not Javascript. You will need to either print it explicitly or store that into the variable. In the Python terminal or Python Notebook, you can just type out a variable and ask for a result, but this does not apply to running code as a Python file.

CrashtestEnigma commented 3 years ago

@BrandonKMLee oh i see. thank you for correcting me, i'm sure i can learn from this.

priyabratap commented 2 years ago

I am facing the same issue, Please find the below output.

Traceback (most recent call last): File "/Users/priyabratajena/projects/pj-scripts/python/content_moderation/challenge_creation.py", line 10, in <module> from profanity_check import predict, predict_prob File "/Users/priyabratajena/projects/pj-scripts/python/content_moderation/pjenv/lib/python3.9/site-packages/profanity_check/__init__.py", line 1, in <module> from .profanity_check import predict, predict_prob File "/Users/priyabratajena/projects/pj-scripts/python/content_moderation/pjenv/lib/python3.9/site-packages/profanity_check/profanity_check.py", line 3, in <module> from sklearn.externals import joblib ImportError: cannot import name 'joblib' from 'sklearn.externals' (/Users/priyabratajena/projects/pj-scripts/python/content_moderation/pjenv/lib/python3.9/site-packages/sklearn/externals/__init__.py)

I changed the import statement in this line /Users/priyabratajena/projects/pj-scripts/python/content_moderation/pjenv/lib/python3.9/site-packages/profanity_check/profanity_check.py" into import joblib

(pjenv) priyabratajena@Priyabratas-MacBook-Pro content_moderation % python3 challenge_creation.py /Users/priyabratajena/projects/pj-scripts/python/content_moderation/pjenv/lib/python3.9/site-packages/sklearn/base.py:324: UserWarning: Trying to unpickle estimator CountVectorizer from version 0.20.2 when using version 1.0.1. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to: https://scikit-learn.org/stable/modules/model_persistence.html#security-maintainability-limitations warnings.warn( Traceback (most recent call last): File "/Users/priyabratajena/projects/pj-scripts/python/content_moderation/challenge_creation.py", line 10, in <module> from profanity_check import predict, predict_prob File "/Users/priyabratajena/projects/pj-scripts/python/content_moderation/pjenv/lib/python3.9/site-packages/profanity_check/__init__.py", line 1, in <module> from .profanity_check import predict, predict_prob File "/Users/priyabratajena/projects/pj-scripts/python/content_moderation/pjenv/lib/python3.9/site-packages/profanity_check/profanity_check.py", line 7, in <module> model = joblib.load(pkg_resources.resource_filename('profanity_check', 'data/model.joblib')) File "/Users/priyabratajena/projects/pj-scripts/python/content_moderation/pjenv/lib/python3.9/site-packages/joblib/numpy_pickle.py", line 587, in load obj = _unpickle(fobj, filename, mmap_mode) File "/Users/priyabratajena/projects/pj-scripts/python/content_moderation/pjenv/lib/python3.9/site-packages/joblib/numpy_pickle.py", line 506, in _unpickle obj = unpickler.load() File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pickle.py", line 1212, in load dispatch[key[0]](self) File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pickle.py", line 1528, in load_global klass = self.find_class(module, name) File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pickle.py", line 1579, in find_class __import__(module, level=0) ModuleNotFoundError: No module named 'sklearn.svm.classes' (pjenv) priyabratajena@Priyabratas-MacBook-Pro content_moderation %

I tried the above solutions and it's not working

python 3.9

Package Version


boto3 1.19.10 botocore 1.22.10 jmespath 0.10.0 joblib 1.1.0 numpy 1.21.3 pip 21.1.1 profanity-check 1.0.3 PyMySQL 1.0.2 python-dateutil 2.8.2 s3transfer 0.5.0 scikit-learn 1.0.1 scipy 1.7.1 setuptools 56.0.0 six 1.16.0 threadpoolctl 3.0.0 urllib3 1.26.7

@dimitrismistriotis @vzhou842 @vchulski

menkotoglou commented 2 years ago

@priyabratap this library is deprecated. You could find an active alternative here and here.

priyabratap commented 2 years ago

@koti the alternative also was not working. Just I created a new venv and it started working with alt-profanity-check.

Thanks a lot

menkotoglou commented 2 years ago

OK