导入keras和tensorflow时出错

2024-04-09

I used from keras.layers import dot并收到此错误作为回报:

c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()
     17         try:
---> 18             fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
     19         except ImportError:

c:\users\prashasti\appdata\local\programs\python\python37-32\lib\imp.py in find_module(name, path)
    295     else:
--> 296         raise ImportError(_ERR_MSG.format(name), name=name)
    297 

ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

ModuleNotFoundError                       Traceback (most recent call last)
c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
     40     sys.setdlopenflags(_default_dlopen_flags | ctypes.RTLD_GLOBAL)
---> 41   from tensorflow.python.pywrap_tensorflow_internal import *
     42   from tensorflow.python.pywrap_tensorflow_internal import __version__

c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in <module>
     27             return _mod
---> 28     _pywrap_tensorflow_internal = swig_import_helper()
     29     del swig_import_helper

c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()
     19         except ImportError:
---> 20             import _pywrap_tensorflow_internal
     21             return _pywrap_tensorflow_internal

ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\keras\__init__.py in <module>
      2 try:
----> 3     from tensorflow.keras.layers.experimental.preprocessing import RandomRotation
      4 except ImportError:

c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\__init__.py in <module>
     23 # pylint: disable=wildcard-import
---> 24 from tensorflow.python import *
     25 # pylint: enable=wildcard-import

c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\__init__.py in <module>
     48 
---> 49 from tensorflow.python import pywrap_tensorflow
     50 

c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
     51 above this error message when asking for help.""" % traceback.format_exc()
---> 52   raise ImportError(msg)
     53 

ImportError: Traceback (most recent call last):
  File "c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
  File "c:\users\prashasti\appdata\local\programs\python\python37-32\lib\imp.py", line 296, in find_module
    raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
    import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-14-884a93be26a0> in <module>
----> 1 from keras.layers import dot

c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\keras\__init__.py in <module>
      4 except ImportError:
      5     raise ImportError(
----> 6         'Keras requires TensorFlow 2.2 or higher. '
      7         'Install TensorFlow via `pip install tensorflow`')
      8 

ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow`

我升级了张量流。也重新安装了但没有用。


我有 CUDA 10.0 和 cuDNN 7.6.4 我也收到以下错误

ImportError:Keras 需要 TensorFlow 2.2 或更高版本。通过以下方式安装 TensorFlowpip install tensorflow

我所做的是首先卸载所有东西,比如没有 python、没有 anaconda、没有虚拟环境。

然后执行以下步骤:

  1. 将 anaconda win 64 与 python 3.7 作为一个包安装
  2. Anaconda安装后,需要设置路径C:\Users\username\Anaconda3\Scripts
  3. 更新点
  4. 康达更新
  5. conda 创建-n tf20 python=3.7
  6. pip安装numpy
  7. pip install "tensorflow>=1.15,
  8. pip install "tensorflow-gpu>=1.15,
  9. pip install keras(使用最新的2.4.2安装)
  10. pip install --升级tensorflow-hub
  11. pip install keras==2.2.4(降级到2.2.4)

现在keras运行tensorflow 1.15 也许您可以在步骤 9 中执行 pip install keras==2.2.4 并删除步骤 11。 在卸载所有内容之前,只需尝试一次上述从步骤 2 开始的步骤。如果有效,您可以节省时间。 祝你好运 :)

请告诉我这是否对您有用。

-Thanks

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

导入keras和tensorflow时出错 的相关文章

随机推荐