Reputation: 959
Does anyone know how to solve this error? I have tensorflow installed as I am using Anaconda Navigator and I get this error when trying to compile my model on Jupyter Notebook.
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3326, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-45-a28ca810f51d>", line 5, in <module>
keras.layers.Flatten(input_shape=(39)),
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow_core\python\keras\layers\core.py", line 570, in __init__
super(Flatten, self).__init__(**kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow_core\python\training\tracking\base.py", line 457, in _method_wrapper
result = method(self, *args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow_core\python\keras\engine\base_layer.py", line 363, in __init__
batch_input_shape = (batch_size,) + tuple(kwargs['input_shape'])
TypeError: 'int' object is not iterable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2040, in showtraceback
stb = value._render_traceback_()
AttributeError: 'TypeError' object has no attribute '_render_traceback_'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 1101, in get_records
return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 319, in wrapped
return f(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 353, in _fixed_getinnerframes
records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
File "C:\ProgramData\Anaconda3\lib\inspect.py", line 1502, in getinnerframes
frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)
File "C:\ProgramData\Anaconda3\lib\inspect.py", line 1460, in getframeinfo
filename = getsourcefile(frame) or getfile(frame)
File "C:\ProgramData\Anaconda3\lib\inspect.py", line 696, in getsourcefile
if getattr(getmodule(object, filename), '__loader__', None) is not None:
File "C:\ProgramData\Anaconda3\lib\inspect.py", line 733, in getmodule
if ismodule(module) and hasattr(module, '__file__'):
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
module = self._load()
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "C:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow_core\contrib\__init__.py", line 39, in <module>
from tensorflow.contrib import compiler
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow_core\contrib\compiler\__init__.py", line 21, in <module>
from tensorflow.contrib.compiler import jit
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow_core\contrib\compiler\__init__.py", line 22, in <module>
from tensorflow.contrib.compiler import xla
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow_core\contrib\compiler\xla.py", line 22, in <module>
from tensorflow.python.estimator import model_fn as model_fn_lib
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow_core\python\estimator\model_fn.py", line 26, in <module>
from tensorflow_estimator.python.estimator import model_fn
File "C:\Users\nxf65465\AppData\Roaming\Python\Python37\site-packages\tensorflow_estimator\python\estimator\model_fn.py", line 29, in <module>
from tensorflow.python.types import core
ModuleNotFoundError: No module named 'tensorflow.python.types'
The installed versions are:
Tensorflow Version: 2.3.1 conda version: 4.8.3
Upvotes: 2
Views: 10459
Reputation: 69
Probably you're using a Tensorflow version == 1.15, try to execute in your terminal the next line:
pip install tensorflow-estimator==1.15.0
Upvotes: 0
Reputation: 1028
For the benefit of posterity... I had the same problem with tensorflow.python.types and it did not require a resintallation of tensorflow to resolve: I was running TF1.15 but had somehow managed to get tensorflow-estimator 2.4 installed as well.
Removing TE 2.4 (and the wrong version of tensorboard) and making sure I had TF 1.15.1 and all was well again.
To note in passing, the mangled environment might also have been responsible for the strange "cannot load the convolution algorithm" error with cuDNN.
I make no specific claims, merely adduce evidence.
Upvotes: 1
Reputation: 11
Having installed tensorflow with Bazel package builder, I reinstall tensorflow with:
pip install tensorflow==2.0 --user
Upvotes: 1
Reputation: 11
Having installed tensorflow with Bazel package builder, shall I reinstall tensor flow with:
pip install tensorflow==2.0 --user
Because I have the same error:
from tensorflow.python.types import core ModuleNotFoundError: No module named 'tensorflow.python.types'
When I run TF but no Anaconda involved... It is from pycharm.
Upvotes: 0
Reputation: 959
Downgrading to tensorflow 2.0 worked for me.
pip install tensorflow==2.0 --user
I think it is because of .dll dependencies but I am not sure.
Upvotes: 1