AttributeError: 'module' object has no attribute 'computation' - python

Im trying to use Keras (Sequential) but I get the following error when I try to import it:
File "kaggle_titanic_keras.py", line 3, in <module>
from keras.models import Sequential
File "/anaconda/lib/python2.7/site-packages/keras/__init__.py", line 4, in <module>
from . import applications
File "/anaconda/lib/python2.7/site-packages/keras/applications/__init__.py", line 1, in <module>
from .vgg16 import VGG16
File "/anaconda/lib/python2.7/site-packages/keras/applications/vgg16.py", line 14, in <module>
from ..models import Model
File "/anaconda/lib/python2.7/site-packages/keras/models.py", line 14, in <module>
from . import layers as layer_module
File "/anaconda/lib/python2.7/site-packages/keras/layers/__init__.py", line 4, in <module>
from ..engine import Layer
File "/anaconda/lib/python2.7/site-packages/keras/engine/__init__.py", line 8, in <module>
from .training import Model
File "/anaconda/lib/python2.7/site-packages/keras/engine/training.py", line 24, in <module>
from .. import callbacks as cbks
File "/anaconda/lib/python2.7/site-packages/keras/callbacks.py", line 25, in <module>
from tensorflow.contrib.tensorboard.plugins import projector
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/__init__.py", line 30, in <module>
from tensorflow.contrib import factorization
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/factorization/__init__.py", line 24, in <module>
from tensorflow.contrib.factorization.python.ops.gmm import *
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/factorization/python/ops/gmm.py", line 27, in <module>
from tensorflow.contrib.learn.python.learn.estimators import estimator
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/__init__.py", line 87, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/python/__init__.py", line 23, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/__init__.py", line 25, in <module>
from tensorflow.contrib.learn.python.learn import estimators
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/__init__.py", line 297, in <module>
from tensorflow.contrib.learn.python.learn.estimators.dnn import DNNClassifier
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn.py", line 29, in <module>
from tensorflow.contrib.learn.python.learn.estimators import dnn_linear_combined
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn_linear_combined.py", line 31, in <module>
from tensorflow.contrib.learn.python.learn.estimators import estimator
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 49, in <module>
from tensorflow.contrib.learn.python.learn.learn_io import data_feeder
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/learn_io/__init__.py", line 21, in <module>
from tensorflow.contrib.learn.python.learn.learn_io.dask_io import extract_dask_data
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/learn_io/dask_io.py", line 26, in <module>
import dask.dataframe as dd
File "/anaconda/lib/python2.7/site-packages/dask/dataframe/__init__.py", line 3, in <module>
from .core import (DataFrame, Series, Index, _Frame, map_partitions,
File "/anaconda/lib/python2.7/site-packages/dask/dataframe/core.py", line 38, in <module>
pd.computation.expressions.set_use_numexpr(False)
AttributeError: 'module' object has no attribute 'computation'
Im running Python 2.7, TensorFlow 1.1 , Keras 2.0.3 and 'upgraded' to Pandas 0.20.1 yesterday which I suspect is causing the problem but the error message says nothing about it.

Update dask to 0.15.0 will solve the issue
update cmd: conda update dask
input pip show dask will show follow message
Name: dask
Version: 0.15.0
Summary: Parallel PyData with Task Scheduling
Home-page: http://github.com/dask/dask/
Author: Matthew Rocklin
Author-email: mrocklin#gmail.com
License: BSD
Location: c:\anaconda3\lib\site-packages
Requires:

dask-0.14.3 works and eliminates the import error

I reverted back to Pandas 0.19.2 and it resolved this problem.

The full command I use is
conda install pandas=0.19.2
and answer y to downgrade the pandas and it worked now.

I had installed below versions:
python 3.5
tensorflow 1.2.1
pandas 0.21
dask 0.15.3
and was getting the following error:
pd.core.computation.expressions.set_use_numexpr(False)
AttributeError: 'module' object has no attribute 'expressions'
I downgraded to pandas 0.19.2 and dask 0.15.0 and the python script worked fine!

Related

I cannot test installation of the Tensorflow Object Detection API in Google Colab

I'm just starting to learn how to use the ML models in the Tensorflow Object Detection API on Google Colab and so I'm trying to follow the documentation very carefully. After installing the libraries and packages, I'm testing the installation using the command from https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html:
python object_detection/builders/model_builder_tf2_test.py
But I get the following error:
Traceback (most recent call last):
File "object_detection/builders/model_builder_tf2_test.py", line 24, in <module>
from object_detection.builders import model_builder
File "/usr/local/lib/python3.7/dist-packages/object_detection/builders/model_builder.py", line 37, in <module>
from object_detection.meta_architectures import deepmac_meta_arch
File "/usr/local/lib/python3.7/dist-packages/object_detection/meta_architectures/deepmac_meta_arch.py", line 20, in <module>
from object_detection.models.keras_models import resnet_v1
File "/usr/local/lib/python3.7/dist-packages/object_detection/models/keras_models/resnet_v1.py", line 28, in <module>
from keras.applications import resnet # pylint:disable=g-import-not-at-top
File "/usr/local/lib/python3.7/dist-packages/keras/__init__.py", line 25, in <module>
from keras import models
File "/usr/local/lib/python3.7/dist-packages/keras/models.py", line 20, in <module>
from keras import metrics as metrics_module
File "/usr/local/lib/python3.7/dist-packages/keras/metrics.py", line 27, in <module>
from keras import activations
File "/usr/local/lib/python3.7/dist-packages/keras/activations.py", line 20, in <module>
from keras.layers import advanced_activations
File "/usr/local/lib/python3.7/dist-packages/keras/layers/__init__.py", line 93, in <module>
from keras.layers.core import Masking
File "/usr/local/lib/python3.7/dist-packages/keras/layers/core/__init__.py", line 20, in <module>
from keras.layers.core.dropout import Dropout
File "/usr/local/lib/python3.7/dist-packages/keras/layers/core/dropout.py", line 26, in <module>
class Dropout(base_layer.BaseRandomLayer):
AttributeError: module 'keras.engine.base_layer' has no attribute 'BaseRandomLayer'
Even after importing keras version 2.0, it still not working, what I can do to solve this issue, thanks
Solved it: tensorflow version 2.5.0 is not compatible with the code provided. I had to install 2.8.0 so that it will work

ImportError: cannot import name 'export_saved_model' from 'tensorflow.python.keras.saving.saved_model'

While running yolo detection on webcam, I came across this error
ImportError: cannot import name 'export_saved_model' from 'tensorflow.python.keras.saving.saved_model'
and its indicated on this line
from yolov3_tf2.models import YoloV3, YoloV3Tiny
I saw this similar question but it is of no use for me.
I did tried this..
conda uninstall -y tensorflow
pip uninstall tensorflow
pip uninstall keras
and then
conda create -n tf tensorflow
conda activate tf
and still the error persists..
Here is the full traceback call..
Traceback (most recent call last):
File "d:/Github/cloned repo/Object-Detection-API/load_weights.py", line 4, in <module>
from yolov3_tf2.models import YoloV3, YoloV3Tiny
File "d:\Github\cloned repo\Object-Detection-API\yolov3_tf2\models.py", line 5, in <module>
from tensorflow.keras import Model
File "D:\Anaconda\lib\site-packages\tensorflow\keras\__init__.py", line 14, in <module>
from . import activations
File "D:\Anaconda\lib\site-packages\tensorflow\keras\activations\__init__.py", line 10, in <module>
from tensorflow.python.keras.activations import deserialize
File "D:\Anaconda\lib\site-packages\tensorflow\python\__init__.py", line 83, in <module>
from tensorflow.python import keras
File "D:\Anaconda\lib\site-packages\tensorflow\python\keras\__init__.py", line 24, in <module>
from tensorflow.python.keras import activations
File "D:\Anaconda\lib\site-packages\tensorflow\python\keras\activations.py", line 24, in <module>
from tensorflow.python.keras.utils.generic_utils import deserialize_keras_object
File "D:\Anaconda\lib\site-packages\tensorflow\python\keras\utils\__init__.py", line 39, in <module>
from tensorflow.python.keras.utils.multi_gpu_utils import multi_gpu_model
File "D:\Anaconda\lib\site-packages\tensorflow\python\keras\utils\multi_gpu_utils.py", line 22, in <module>
from tensorflow.python.keras.engine.training import Model
File "D:\Anaconda\lib\site-packages\tensorflow\python\keras\engine\training.py", line 43, in <module>
from tensorflow.python.keras.engine.network import Network
File "D:\Anaconda\lib\site-packages\tensorflow\python\keras\engine\network.py", line 40, in <module>
from tensorflow.python.keras.saving import hdf5_format
File "D:\Anaconda\lib\site-packages\tensorflow\python\keras\saving\__init__.py", line 31, in <module>
from tensorflow.python.keras.saving.saved_model import export_saved_model
ImportError: cannot import name 'export_saved_model' from 'tensorflow.python.keras.saving.saved_model' (D:\Anaconda\lib\site-packages\tensorflow\python\keras\saving\saved_model\__init__.py)
Help me solve this error..
Thanks in advance.

cannot load tensor flow [duplicate]

This question already has answers here:
ImportError: cannot import name 'abs'
(9 answers)
Closed 4 years ago.
My code is, simply, executing in pycharm:
import tensorflow as tf
I get the following messages:
Traceback (most recent call last):
File "/Users/peterwills/PyCharmProjects/Kaggle/Salt_pretrain/pretrain_model.py", line 1, in <module>
import tensorflow as tf
File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/__init__.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 81, in <module>
from tensorflow.python import keras
File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/keras/__init__.py", line 24, in <module>
from tensorflow.python.keras import activations
File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/keras/activations/__init__.py", line 22, in <module>
from tensorflow.python.keras._impl.keras.activations import elu
File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/__init__.py", line 21, in <module>
from tensorflow.python.keras._impl.keras import activations
File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/activations.py", line 23, in <module>
from tensorflow.python.keras._impl.keras import backend as K
File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/backend.py", line 38, in <module>
from tensorflow.python.layers import base as tf_base_layers
File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/layers/base.py", line 25, in <module>
from tensorflow.python.keras.engine import base_layer
File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/keras/engine/__init__.py", line 21, in <module>
from tensorflow.python.keras.engine.base_layer import InputSpec
File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 33, in <module>
from tensorflow.python.keras import backend
File "/Users/peterwills/PyCharmProjects/anaconda3/envs/May2018_1/lib/python3.6/site-packages/tensorflow/python/keras/backend/__init__.py", line 22, in <module>
from tensorflow.python.keras._impl.keras.backend import abs
ImportError: cannot import name 'abs'
My tensor flow version is 1.9.0.
My Keras version is: 2.2.2
...cboth in anaconda
I have tried uninstalling tensor flow and protobuf, as suggested elsewhere, to no avail.
Can anyone advise on this?
I solved this by making a new virtual environment in anaconda and re-installing tensor flow (and a bunch of other unrelated stuff). A bit much, I agree but "only way to be sure".

How to install tflearn, Anaconda Ubuntu 16.04

I am using Anaconda on ubuntu 16.04.
I try pip install tflearn on terminal and says ok.
But if I try to check the tflearn version, I receive this log.
I appreciate any hint to solve this issue.
Traceback (most recent call last):
File "/media/libardo/Datos/Proyectos/Libardo/2017/Proyectos/Kaggle/MBA/prueba_TF_Version.py", line 12, in <module>
import tflearn as tfl; print(tfl.__version__)
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tflearn/__init__.py", line 4, in <module>
from . import config
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tflearn/config.py", line 5, in <module>
from .variables import variable
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tflearn/variables.py", line 7, in <module>
from tensorflow.contrib.framework.python.ops import add_arg_scope as contrib_add_arg_scope
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/__init__.py", line 30, in <module>
from tensorflow.contrib import factorization
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/factorization/__init__.py", line 24, in <module>
from tensorflow.contrib.factorization.python.ops.gmm import *
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/factorization/python/ops/gmm.py", line 27, in <module>
from tensorflow.contrib.learn.python.learn.estimators import estimator
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/__init__.py", line 87, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/__init__.py", line 23, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/__init__.py", line 25, in <module>
from tensorflow.contrib.learn.python.learn import estimators
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/estimators/__init__.py", line 297, in <module>
from tensorflow.contrib.learn.python.learn.estimators.dnn import DNNClassifier
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn.py", line 29, in <module>
from tensorflow.contrib.learn.python.learn.estimators import dnn_linear_combined
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn_linear_combined.py", line 31, in <module>
from tensorflow.contrib.learn.python.learn.estimators import estimator
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 49, in <module>
from tensorflow.contrib.learn.python.learn.learn_io import data_feeder
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/learn_io/__init__.py", line 21, in <module>
from tensorflow.contrib.learn.python.learn.learn_io.dask_io import extract_dask_data
File "/home/libardo/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/learn_io/dask_io.py", line 26, in <module>
import dask.dataframe as dd
File "/home/libardo/anaconda3/lib/python3.6/site-packages/dask/dataframe/__init__.py", line 3, in <module>
from .core import (DataFrame, Series, Index, _Frame, map_partitions,
File "/home/libardo/anaconda3/lib/python3.6/site-packages/dask/dataframe/core.py", line 38, in <module>
pd.computation.expressions.set_use_numexpr(False)
AttributeError: module 'pandas' has no attribute 'computation'
Maybe the pandas version is old. Try follow the following steps:
https://www.scipy.org/install.html
Another reason for your problem can be due your version of Python, like too the version of your pip. Please, verify if your pip have that libraries with:
pip list
pip2 list
pip3 list
The use of this commands depends your Python and pip version.

Error in running keras for deep learning in ubuntu 14.04

I had implemented a neural net architecture in keras using tensor flow as a backend.
Which is working fine in last month but when I tried to run the code again it gives a series of errors. I tried to uninstall my packages installed and reinstall it but it never worked for me. I also tried the same combination with theano as a backend but it still gives me error.
I am attaching the traceback of the hope I could get a better solution for my question.
Using TensorFlow backend.
Traceback (most recent call last):
File "DeepNeuralNetwork.py", line 9, in <module>
from keras.models import Sequential
File "/usr/local/lib/python2.7/dist-packages/keras/__init__.py", line 2, in <module>
from . import backend
File "/usr/local/lib/python2.7/dist-packages/keras/backend/__init__.py", line 69, in <module>
from .tensorflow_backend import *
File "/usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py", line 1, in <module>
import tensorflow as tf
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 65, in <module>
import tensorflow.contrib as contrib
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/__init__.py", line 28, in <module>
from tensorflow.contrib import learn
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/__init__.py", line 72, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/__init__.py", line 23, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/__init__.py", line 25, in <module>
from tensorflow.contrib.learn.python.learn import estimators
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/__init__.py", line 23, in <module>
from tensorflow.contrib.learn.python.learn.estimators.autoencoder import TensorFlowDNNAutoencoder
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/autoencoder.py", line 25, in <module>
from tensorflow.contrib.learn.python.learn.estimators.base import TensorFlowBaseTransformer
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/base.py", line 34, in <module>
from tensorflow.contrib.learn.python.learn.estimators import estimator
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 38, in <module>
from tensorflow.contrib.learn.python.learn.io import data_feeder
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/io/__init__.py", line 22, in <module>
from tensorflow.contrib.learn.python.learn.io.dask_io import extract_dask_data
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/io/dask_io.py", line 26, in <module>
import dask.dataframe as dd
File "/usr/local/lib/python2.7/dist-packages/dask/dataframe/__init__.py", line 5, in <module>
from .io import (from_array, from_pandas, from_bcolz,
File "/usr/local/lib/python2.7/dist-packages/dask/dataframe/io/__init__.py", line 6, in <module>
from .csv import read_csv, to_csv, read_table
File "/usr/local/lib/python2.7/dist-packages/dask/dataframe/io/csv.py", line 147, in <module>
CPU_COUNT = psutil.cpu_count()
AttributeError: 'module' object has no attribute 'cpu_count'
As you can see from the last lines of the backtrace:
File "/usr/local/lib/python2.7/dist-packages/dask/dataframe/io/csv.py", line 147, in <module>
CPU_COUNT = psutil.cpu_count()
AttributeError: 'module' object has no attribute 'cpu_count'
the error is due to dask trying to call the attribute cpu_count of the module psutil.
This is probably due to some wrong version of psutil installed, and should be solved by simply upgrading or reinstalling it.

Categories

Resources