Abd*_*hab 8 python installation anaconda tensorflow
我已经安装了带有 CUDA 10.1、cuDNN SDK = 7.6 的 TensorFlow 2.0 以及所有不同的库,例如 pandas、sci-kit learn、Keras、NumPy、Gensim 等。此错误可能是由于新的 TensorFlow 版本造成的。当我尝试通过运行此确认代码来确认时。我收到错误。请帮忙。
\n\nimport sys\n\nimport tensorflow.keras\nimport pandas as pd\nimport sklearn as sk\nimport tensorflow as tf\n\nprint(f"Tensor Flow Version: {tf.__version__}")\nprint(f"Keras Version: {tensorflow.keras.__version__}")\nprint()\nprint(f"Python {sys.version}")\nprint(f"Pandas {pd.__version__}")\nprint(f"Scikit-Learn {sk.__version__}")\nprint("GPU is", "available" if tf.test.is_gpu_available() else "NOT AVAILABLE")\n
Run Code Online (Sandbox Code Playgroud)\n\n我收到错误:
\n\nWARNING: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.\nInstructions for updating:\nThe 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`.\nWARNING: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.\nInstructions for updating:\nThe 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`.\nERROR:root:Internal Python error in the inspect module.\nBelow is the traceback from this internal error.\n\nTraceback (most recent call last):\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\IPython\\core\\interactiveshell.py", line 3331, in run_code\n exec(code_obj, self.user_global_ns, self.user_ns)\n File "<ipython-input-1-0b3eb45acbe5>", line 3, in <module>\n import tensorflow.keras\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\__init__.py", line 98, in <module>\n from tensorflow_core import *\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow_core\\__init__.py", line 40, in <module>\n from tensorflow.python.tools import module_util as _module_util\nModuleNotFoundError: No module named \'tensorflow.python.tools\'; \'tensorflow.python\' is not a package\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\IPython\\core\\interactiveshell.py", line 2044, in showtraceback\n stb = value._render_traceback_()\nAttributeError: \'ModuleNotFoundError\' object has no attribute \'_render_traceback_\'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\IPython\\core\\ultratb.py", line 1151, in get_records\n return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\IPython\\core\\ultratb.py", line 319, in wrapped\n return f(*args, **kwargs)\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\IPython\\core\\ultratb.py", line 353, in _fixed_getinnerframes\n records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\inspect.py", line 1502, in getinnerframes\n frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\inspect.py", line 1460, in getframeinfo\n filename = getsourcefile(frame) or getfile(frame)\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\inspect.py", line 696, in getsourcefile\n if getattr(getmodule(object, filename), \'__loader__\', None) is not None:\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\inspect.py", line 733, in getmodule\n if ismodule(module) and hasattr(module, \'__file__\'):\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\__init__.py", line 50, in __getattr__\n module = self._load()\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\__init__.py", line 44, in _load\n module = _importlib.import_module(self.__name__)\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\importlib\\__init__.py", line 127, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n File "<frozen importlib._bootstrap>", line 1006, in _gcd_import\n File "<frozen importlib._bootstrap>", line 983, in _find_and_load\n File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked\n File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed\n File "<frozen importlib._bootstrap>", line 1006, in _gcd_import\n File "<frozen importlib._bootstrap>", line 983, in _find_and_load\n File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked\n File "<frozen importlib._bootstrap>", line 677, in _load_unlocked\n File "<frozen importlib._bootstrap_external>", line 728, in exec_module\n File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow_core\\__init__.py", line 45, in <module>\n from . _api.v2 import compat\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow_core\\_api\\v2\\compat\\__init__.py", line 23, in <module>\n from . import v1\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow_core\\_api\\v2\\compat\\v1\\__init__.py", line 40, in <module>\n from . import experimental\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow_core\\_api\\v2\\compat\\v1\\experimental\\__init__.py", line 11, in <module>\n from tensorflow.python.ops.control_flow_v2_toggles import output_all_intermediates\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow_core\\python\\ops\\control_flow_v2_toggles.py", line 24, in <module>\n from tensorflow.python.ops import control_flow_util_v2\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow_core\\python\\ops\\control_flow_util_v2.py", line 28, in <module>\n from tensorflow.python.keras.engine import base_layer_utils\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow_core\\python\\keras\\__init__.py", line 27, in <module>\n from tensorflow.python.keras import applications\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow_core\\python\\keras\\applications\\__init__.py", line 25, in <module>\n from tensorflow.python.keras import engine\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow_core\\python\\keras\\engine\\__init__.py", line 23, in <module>\n from tensorflow.python.keras.engine.base_layer import Layer\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow_core\\python\\keras\\engine\\base_layer.py", line 56, in <module>\n from tensorflow.python.keras.saving.saved_model import layer_serialization\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow_core\\python\\keras\\saving\\__init__.py", line 20, in <module>\n from tensorflow.python.keras.saving.hdf5_format import load_attributes_from_hdf5_group\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow_core\\python\\keras\\saving\\hdf5_format.py", line 32, in <module>\n from tensorflow.python.keras.utils import conv_utils\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow_core\\python\\keras\\utils\\__init__.py", line 38, in <module>\n from tensorflow.python.keras.utils.multi_gpu_utils import multi_gpu_model\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow_core\\python\\keras\\utils\\multi_gpu_utils.py", line 22, in <module>\n from tensorflow.python.keras.engine.training import Model\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow_core\\python\\keras\\engine\\training.py", line 42, in <module>\n from tensorflow.python.keras import metrics as metrics_module\n File "C:\\Users\\Abdul\\.conda\\envs\\tensorflow\\lib\\site-packages\\tensorflow_core\\python\\keras\\metrics.py", line 34, in <module>\n from tensorflow.python.keras.engine.base_layer import Layer\nImportError: 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)\n---------------------------------------------------------------------------\n\n\xe2\x80\x8b\n
Run Code Online (Sandbox Code Playgroud)\n
我在 Windows 10 虚拟机上遇到了同样的错误。由于您使用的是 Anaconda,请尝试:
pip uninstall tensorflow
然后尝试conda install tensorflow
然后尝试通过以下方式导入 Keras 包:from tensorflow.keras.xxx import xxx
正如上面的评论中提到的,可能值得尝试在 conda 中设置虚拟环境,并在那里安装所需的软件包。
归档时间: |
|
查看次数: |
32262 次 |
最近记录: |