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

joblib fails at import on Python3.8 #917

Closed
pierreglaser opened this issue Jul 25, 2019 · 5 comments
Closed

joblib fails at import on Python3.8 #917

pierreglaser opened this issue Jul 25, 2019 · 5 comments

Comments

@pierreglaser
Copy link
Contributor

pierreglaser commented Jul 25, 2019

>>> import joblib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pierreglaser/.virtualenvs/py38/lib/python3.8/site-packages/joblib/__init__.py", line 119, in <module>
    from .parallel import Parallel
  File "/home/pierreglaser/.virtualenvs/py38/lib/python3.8/site-packages/joblib/parallel.py", line 28, in <module>
    from ._parallel_backends import (FallbackToBackend, MultiprocessingBackend,
  File "/home/pierreglaser/.virtualenvs/py38/lib/python3.8/site-packages/joblib/_parallel_backends.py", line 22, in <module>
    from .executor import get_memmapping_executor
  File "/home/pierreglaser/.virtualenvs/py38/lib/python3.8/site-packages/joblib/executor.py", line 14, in <module>
    from .externals.loky.reusable_executor import get_reusable_executor
  File "/home/pierreglaser/.virtualenvs/py38/lib/python3.8/site-packages/joblib/externals/loky/__init__.py", line 12, in <module>
    from .backend.reduction import set_loky_pickler
  File "/home/pierreglaser/.virtualenvs/py38/lib/python3.8/site-packages/joblib/externals/loky/backend/reduction.py", line 125, in <module>
    from joblib.externals import cloudpickle  # noqa: F401
  File "/home/pierreglaser/.virtualenvs/py38/lib/python3.8/site-packages/joblib/externals/cloudpickle/__init__.py", line 3, in <module>
    from .cloudpickle import *
  File "/home/pierreglaser/.virtualenvs/py38/lib/python3.8/site-packages/joblib/externals/cloudpickle/cloudpickle.py", line 152, in <module>
    _cell_set_template_code = _make_cell_set_template_code()
  File "/home/pierreglaser/.virtualenvs/py38/lib/python3.8/site-packages/joblib/externals/cloudpickle/cloudpickle.py", line 133, in _make_cell_set_template_code
    return types.CodeType(
TypeError: an integer is required (got type bytes)

The last joblib pypi releases only has cloudpickle0.8 which is not compatible with python3.8. We should release a new joblib soon.

Other errors due to old cloudpickle: #909

@ogrisel ogrisel closed this as completed Oct 24, 2019
@nok
Copy link

nok commented Dec 17, 2019

Is this issue fixed with PR #936?

In my case I installed scikit-learn==0.20 with Python 3.8 and imported a toy dataset:

_________________________________________ ERROR collecting tests/EstimatorTest.py _________________________________________
tests/EstimatorTest.py:16: in <module>
    from sklearn.datasets import load_iris
/usr/local/miniconda3/envs/porter_38_022/lib/python3.8/site-packages/sklearn/__init__.py:64: in <module>
    from .base import clone
/usr/local/miniconda3/envs/porter_38_022/lib/python3.8/site-packages/sklearn/base.py:13: in <module>
    from .utils.fixes import signature
/usr/local/miniconda3/envs/porter_38_022/lib/python3.8/site-packages/sklearn/utils/__init__.py:13: in <module>
    from .validation import (as_float_array,
/usr/local/miniconda3/envs/porter_38_022/lib/python3.8/site-packages/sklearn/utils/validation.py:27: in <module>
    from ..utils._joblib import Memory
/usr/local/miniconda3/envs/porter_38_022/lib/python3.8/site-packages/sklearn/utils/_joblib.py:18: in <module>
    from ..externals.joblib import __all__   # noqa
/usr/local/miniconda3/envs/porter_38_022/lib/python3.8/site-packages/sklearn/externals/joblib/__init__.py:119: in <module>
    from .parallel import Parallel
/usr/local/miniconda3/envs/porter_38_022/lib/python3.8/site-packages/sklearn/externals/joblib/parallel.py:32: in <module>
    from .externals.cloudpickle import dumps, loads
/usr/local/miniconda3/envs/porter_38_022/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/__init__.py:3: in <module>
    from .cloudpickle import *
/usr/local/miniconda3/envs/porter_38_022/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py:151: in <module>
    _cell_set_template_code = _make_cell_set_template_code()
/usr/local/miniconda3/envs/porter_38_022/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py:132: in _make_cell_set_template_code
    return types.CodeType(
E   TypeError: an integer is required (got type bytes)

Maybe that helps.

@ogrisel
Copy link
Contributor

ogrisel commented Dec 19, 2019

scikit-learn 0.20 embeds an old joblib version and neither support Python 3.8. Use scikit-learn 0.22 and joblib 0.14 or later for Python 3.8 support.

Tgaaly added a commit to agarwalShruti15/motion_signature that referenced this issue Mar 23, 2020
This fixed an error I was seeing: `TypeError: an integer is required (got type bytes)`, similar to this issue: joblib/joblib#917.
@RicardoLuisAraujo
Copy link

scikit-learn 0.20 embeds an old joblib version and neither support Python 3.8. Use scikit-learn 0.22 and joblib 0.14 or later for Python 3.8 support.

You just saved me a day full of headaches, thank you!

@dash-samuel
Copy link

@ogrisel thanks for the tip!

@Carlos1729
Copy link

Carlos1729 commented Jun 17, 2021

I still face Issues with all the requirements satisfied.

Traceback (most recent call last):
File "/anaconda3/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/anaconda3/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/anaconda3/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/Projectfolder/predict_risk/views.py", line 31, in PredictRisk
standard_scalar = GetStandardScalarForHeart()
File "/Projectfolder/predict_risk/data_provider.py", line 32, in GetStandardScalarForHeart
return GetPickleFile(config['heart']['scalar_file'])
File "/projectfolder/predict_risk/data_provider.py", line 27, in GetPickleFile
return pickle.load(open(os.path.join(dir, filepath), "rb"))
File "/anaconda3/lib/python3.8/site-packages/sklearn/init.py", line 65, in
from .utils._show_versions import show_versions
File "/anaconda3/lib/python3.8/site-packages/sklearn/utils/init.py", line 13, in
from .validation import (as_float_array,
File "/anaconda3/lib/python3.8/site-packages/sklearn/utils/validation.py", line 27, in
from ..utils._joblib import Memory
File "/anaconda3/lib/python3.8/site-packages/sklearn/utils/_joblib.py", line 18, in
from ..externals.joblib import all # noqa
File "/anaconda3/lib/python3.8/site-packages/sklearn/externals/joblib/init.py", line 119, in
from .parallel import Parallel
File "/anaconda3/lib/python3.8/site-packages/sklearn/externals/joblib/parallel.py", line 32, in
from .externals.cloudpickle import dumps, loads
File "/anaconda3/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/init.py", line 3, in
from .cloudpickle import *
File "/anaconda3/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py", line 150, in
_cell_set_template_code = _make_cell_set_template_code()
File "/anaconda3/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py", line 131, in _make_cell_set_template_code
return types.CodeType(
TypeError: an integer is required (got type bytes)

@ogrisel

kernc added a commit to kernc/scikit-optimize that referenced this issue Sep 27, 2021
kernc added a commit to kernc/scikit-optimize that referenced this issue Sep 27, 2021
kernc added a commit to kernc/scikit-optimize that referenced this issue Sep 27, 2021
kernc added a commit to kernc/scikit-optimize that referenced this issue Sep 27, 2021
kernc added a commit to kernc/scikit-optimize that referenced this issue Oct 4, 2021
To v0.22.* -- it was released in 2019.
Also this joblib/joblib#917 (comment)

Futher bump tested scikit-learn == 0.24.* -- it is old enough!

The alternative would be to pin equally ancient scipy to
avoid error:

> AttributeError: 'str' object has no attribute 'decode'
kernc added a commit to kernc/scikit-optimize that referenced this issue Oct 4, 2021
To v0.22.* -- it was released in 2019.
Also this joblib/joblib#917 (comment)

Futher bump tested scikit-learn == 0.24.* -- it is old enough!

The alternative would be to pin equally ancient scipy to
avoid error:

> AttributeError: 'str' object has no attribute 'decode'
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

6 participants