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

Unable to import eli5 #34

Open
nkadochn opened this issue Oct 17, 2022 · 3 comments
Open

Unable to import eli5 #34

nkadochn opened this issue Oct 17, 2022 · 3 comments

Comments

@nkadochn
Copy link

I just pip installed eli5 0.13.0 on a new AzureML instance and it is throwing an exception during "import eli5"

The sklearn.feature_selection.base module is deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.feature_selection. Anything that cannot be imported from sklearn.feature_selection is now part of the private API.
Using TensorFlow backend.

AttributeError Traceback (most recent call last)
Input In [59], in <cell line: 1>()
----> 1 import eli5

File /anaconda/envs/azureml_py38/lib/python3.8/site-packages/eli5/init.py:93, in
89 pass
92 try:
---> 93 from .keras import (
94 explain_prediction_keras
95 )
96 except ImportError:
97 # keras is not available
98 pass

File /anaconda/envs/azureml_py38/lib/python3.8/site-packages/eli5/keras/init.py:3, in
1 # -- coding: utf-8 --
----> 3 from .explain_prediction import explain_prediction_keras
4 from .gradcam import gradcam, gradcam_backend

File /anaconda/envs/azureml_py38/lib/python3.8/site-packages/eli5/keras/explain_prediction.py:8, in
5 import PIL
7 import numpy as np
----> 8 import keras
9 import keras.backend as K
10 from keras.models import Model

File /anaconda/envs/azureml_py38/lib/python3.8/site-packages/keras/init.py:25, in
22 from keras import distribute
24 # See b/110718070#comment18 for more details about this import.
---> 25 from keras import models
27 from keras.engine.input_layer import Input
28 from keras.engine.sequential import Sequential

File /anaconda/envs/azureml_py38/lib/python3.8/site-packages/keras/models.py:19, in
16 """Code for model cloning, plus model-related API entries."""
18 import tensorflow.compat.v2 as tf
---> 19 from keras import backend
20 from keras import metrics as metrics_module
21 from keras import optimizer_v1

File /anaconda/envs/azureml_py38/lib/python3.8/site-packages/keras/backend/init.py:1, in
----> 1 from .load_backend import epsilon
2 from .load_backend import set_epsilon
3 from .load_backend import floatx

File /anaconda/envs/azureml_py38/lib/python3.8/site-packages/keras/backend/load_backend.py:90, in
88 elif _BACKEND == 'tensorflow':
89 sys.stderr.write('Using TensorFlow backend.\n')
---> 90 from .tensorflow_backend import *
91 else:
92 # Try and load external backend.
93 try:

File /anaconda/envs/azureml_py38/lib/python3.8/site-packages/keras/backend/tensorflow_backend.py:25, in
22 import numpy as np
23 from distutils.version import StrictVersion
---> 25 from ..utils.generic_utils import transpose_shape
27 py_all = all
28 py_any = any

File /anaconda/envs/azureml_py38/lib/python3.8/site-packages/keras/utils/generic_utils.py:415, in
410 else:
411 return obj.name
414 @tf_contextlib.contextmanager
--> 415 def skip_failed_serialization():
416 global _SKIP_FAILED_SERIALIZATION
417 prev = _SKIP_FAILED_SERIALIZATION

File /anaconda/envs/azureml_py38/lib/python3.8/site-packages/keras/utils/tf_contextlib.py:33, in contextmanager(target)
23 """A tf_decorator-aware wrapper for contextlib.contextmanager.
24
25 Usage is identical to contextlib.contextmanager.
(...)
30 A callable that can be used inside of a with statement.
31 """
32 context_manager = _contextlib.contextmanager(target)
---> 33 return tf.internal.decorator.make_decorator(target, context_manager, 'contextmanager')

AttributeError: module 'tensorflow.compat.v2' has no attribute 'internal'

@nkadochn nkadochn changed the title Unable to import eli5 on new Unable to import eli5 Oct 17, 2022
@lopuhin
Copy link
Contributor

lopuhin commented Oct 17, 2022

Thanks for the report. From the traceback, that looks to be an issue which would happen when you try to import keras as well, could you please check if it's installed correctly?

@nkadochn
Copy link
Author

You are absolutely correct @lopuhin and thank you for the lightning fast response. Now if I select the "Python 3.8 - Pytorch and Tensorflow" enviroment, where Keras is working I can install and import eli5. But if I select "Python 3.8 - AzureML", where Keras is not operational I am unable to import eli5.

Since I am working with just xgboost and do not need Keras / TF environment, what would be the best way for me to import eli5, without triggering Keras issue?

@nkadochn
Copy link
Author

@lopuhin, I also verified that running from tensorflow import keras works perfectly fine.

from tensorflow import keras
keras.version
'2.3.0-tf'

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

2 participants