我已经安装了TensorFlow 2.0与CUDA10.1,cuDNN SDK = 7.6和所有不同的库,如熊猫,sci学习,Keras,NumPy,Gensim等。这个错误可能是由于新的TensorFlow版本。当我试图通过运行这个确认代码来确认它时。我搞错了。帮帮忙吧。
import sys
import tensorflow.keras
import pandas as pd
import sklearn as sk
import tensorflow as tf
print(f"Tensor Flow Version: {tf.__version__}")
print(f"Keras Version: {tensorflow.keras.__version__}")
print()
print(f"Python {sys.version}")
print(f"Pandas {pd.__version__}")
print(f"Scikit-Learn {sk.__version__}")
print("GPU is", "available" if tf.test.is_gpu_available() else "NOT AVAILABLE")
我得到的错误:
WARNING:tensorflow:From C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\python\ops\distributions\distribution.py:265: ReparameterizationType.__init__ (from tensorflow.python.ops.distributions.distribution) is deprecated and will be removed after 2019-01-01.
Instructions for updating:
The TensorFlow Distributions library has moved to TensorFlow Probability (https://github.com/tensorflow/probability). You should update all references to use `tfp.distributions` instead of `tf.distributions`.
WARNING:tensorflow:From C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\python\ops\distributions\bernoulli.py:169: RegisterKL.__init__ (from tensorflow.python.ops.distributions.kullback_leibler) is deprecated and will be removed after 2019-01-01.
Instructions for updating:
The TensorFlow Distributions library has moved to TensorFlow Probability (https://github.com/tensorflow/probability). You should update all references to use `tfp.distributions` instead of `tf.distributions`.
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.
Traceback (most recent call last):
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 3331, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-1-0b3eb45acbe5>", line 3, in <module>
import tensorflow.keras
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow\__init__.py", line 98, in <module>
from tensorflow_core import *
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
from tensorflow.python.tools import module_util as _module_util
ModuleNotFoundError: No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2044, in showtraceback
stb = value._render_traceback_()
AttributeError: 'ModuleNotFoundError' object has no attribute '_render_traceback_'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\IPython\core\ultratb.py", line 1151, in get_records
return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\IPython\core\ultratb.py", line 319, in wrapped
return f(*args, **kwargs)
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\IPython\core\ultratb.py", line 353, in _fixed_getinnerframes
records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\inspect.py", line 1502, in getinnerframes
frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\inspect.py", line 1460, in getframeinfo
filename = getsourcefile(frame) or getfile(frame)
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\inspect.py", line 696, in getsourcefile
if getattr(getmodule(object, filename), '__loader__', None) is not None:
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\inspect.py", line 733, in getmodule
if ismodule(module) and hasattr(module, '__file__'):
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
module = self._load()
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow\__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "C:\Users\Abdul\.conda\envs\tensorflow\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 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
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:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\__init__.py", line 45, in <module>
from . _api.v2 import compat
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\_api\v2\compat\__init__.py", line 23, in <module>
from . import v1
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\_api\v2\compat\v1\__init__.py", line 40, in <module>
from . import experimental
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\_api\v2\compat\v1\experimental\__init__.py", line 11, in <module>
from tensorflow.python.ops.control_flow_v2_toggles import output_all_intermediates
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\python\ops\control_flow_v2_toggles.py", line 24, in <module>
from tensorflow.python.ops import control_flow_util_v2
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\python\ops\control_flow_util_v2.py", line 28, in <module>
from tensorflow.python.keras.engine import base_layer_utils
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\__init__.py", line 27, in <module>
from tensorflow.python.keras import applications
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\applications\__init__.py", line 25, in <module>
from tensorflow.python.keras import engine
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\__init__.py", line 23, in <module>
from tensorflow.python.keras.engine.base_layer import Layer
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\base_layer.py", line 56, in <module>
from tensorflow.python.keras.saving.saved_model import layer_serialization
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\saving\__init__.py", line 20, in <module>
from tensorflow.python.keras.saving.hdf5_format import load_attributes_from_hdf5_group
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\saving\hdf5_format.py", line 32, in <module>
from tensorflow.python.keras.utils import conv_utils
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\utils\__init__.py", line 38, in <module>
from tensorflow.python.keras.utils.multi_gpu_utils import multi_gpu_model
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\utils\multi_gpu_utils.py", line 22, in <module>
from tensorflow.python.keras.engine.training import Model
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 42, in <module>
from tensorflow.python.keras import metrics as metrics_module
File "C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\metrics.py", line 34, in <module>
from tensorflow.python.keras.engine.base_layer import Layer
ImportError: cannot import name 'Layer' from 'tensorflow.python.keras.engine.base_layer' (C:\Users\Abdul\.conda\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\base_layer.py)
---------------------------------------------------------------------------
发布于 2021-01-12 19:54:05
如果在Google上得到此错误,那么工厂重置运行时。单击Runtime,然后工厂重置运行时
发布于 2022-01-04 13:07:52
如果发生在Google Colab
在顶部菜单中单击Runtime
> Restart Runtime
发布于 2020-05-05 02:30:42
我通过下载和安装"Microsoft 2015、2017和2019的C++可再发行版“解决了这个问题。对我起作用了。
先决条件: Python +木星笔记本+ tensorflow安装已经完成
当您“导入tensorflow”时会得到此错误
遵循以下步骤:
步骤1:下载"Microsoft 2015、2017和2019 -社区版可再发行版“
步骤2:在安装Microsoft 2015、2017和2019的C++可再发行版时选择"Python“
步骤3:重新启动计算机一次
步骤4:现在打开木星笔记本和“进口tensorflow”,错误就不会发生了
https://stackoverflow.com/questions/60141916
复制相似问题