Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 导入keras和tensorflow时出错_Python_Tensorflow_Keras_Importerror - Fatal编程技术网

Python 导入keras和tensorflow时出错

Python 导入keras和tensorflow时出错,python,tensorflow,keras,importerror,Python,Tensorflow,Keras,Importerror,我使用了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, des

我使用了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`
c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site packages\tensorflow\python\pywrap\u tensorflow\u internal.py in swig\u import\u helper()
17尝试:
--->18 fp,路径名,description=imp.find_模块(“pywrap_tensorflow_internal”,[dirname(u文件)]
19除恐怖外:
c:\users\prashasti\appdata\local\programs\python\python37-32\lib\imp.py在find_模块中(名称、路径)
295其他:
-->296 raise ImportError(_ERR_MSG.format(name),name=name)
297
ImportError:没有名为“\u pywrap\u tensorflow\u internal”的模块
在处理上述异常期间,发生了另一个异常:
ModuleNotFoundError回溯(上次最近调用)
c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site packages\tensorflow\python\pywrap\u tensorflow.py in
40 sys.setdlopenflags(_default_dlopen_flags | ctypes.RTLD_GLOBAL)
--->41来自tensorflow.python.pywrap\u tensorflow\u内部导入*
42来自tensorflow.python.pywrap\u tensorflow\u内部导入\u版本__
c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site packages\tensorflow\python\pywrap\u tensorflow\u internal.py in
27返回模式
--->28_pywrap_tensorflow_internal=swig_import_helper()
29 del swig_导入帮助程序
c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site packages\tensorflow\python\pywrap\u tensorflow\u internal.py in swig\u import\u helper()
19除恐怖外:
--->20导入pywrap tensorflow internal
21返回pywrap tensorflow internal
ModuleNotFoundError:没有名为“\u pywrap\u tensorflow\u internal”的模块
在处理上述异常期间,发生了另一个异常:
ImportError回溯(最近一次呼叫最后一次)
c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site packages\keras\\uuuu init\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
2.尝试:
---->3来自tensorflow.keras.layers.experimental.preprocessing导入随机旋转
4除恐怖外:
c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site packages\tensorflow\\uuuu init\uuuuuuuuuuuuuuuuuuuu.py in
23#pylint:disable=通配符导入
--->24从tensorflow.python导入*
25#pylint:enable=通配符导入
c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site packages\tensorflow\python\\uuu init\uuuuuuuuuu.py in
48
--->49从tensorflow.python导入pywrap\u tensorflow
50
c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site packages\tensorflow\python\pywrap\u tensorflow.py in
51请求帮助时出现此错误消息。“%traceback.format_exc()
--->52.恐怖主义(味精)
53
ImportError:回溯(最近一次呼叫上次):
文件“c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site packages\tensorflow\python\pywrap\u tensorflow\u internal.py”,第18行,在swig\u import\u helper中
fp,路径名,description=imp.find_模块(“pywrap_tensorflow_internal”,[dirname(u文件)]
文件“c:\users\prashasti\appdata\local\programs\python\python37-32\lib\imp.py”,第296行,在find\u模块中
引发导入错误(_ERR_MSG.format(name),name=name)
ImportError:没有名为“\u pywrap\u tensorflow\u internal”的模块
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site packages\tensorflow\python\pywrap\u tensorflow.py”,第41行,在
从tensorflow.python.pywrap\u tensorflow\u内部导入*
文件“c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site packages\tensorflow\python\pywrap\u tensorflow\u internal.py”,第28行,in
_pywrap\u tensorflow\u internal=swig\u import\u helper()
文件“c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site packages\tensorflow\python\pywrap\u tensorflow\u internal.py”,第20行,在swig\u import\u helper中
导入\u pywrap\u tensorflow\u内部
ModuleNotFoundError:没有名为“\u pywrap\u tensorflow\u internal”的模块
未能加载本机TensorFlow运行时。
看见https://www.tensorflow.org/install/install_sources#common_installation_problems
由于一些常见的原因和解决方案。包括整个堆栈跟踪
以上是请求帮助时的错误消息。
在处理上述异常期间,发生了另一个异常:
ImportError回溯(最近一次呼叫最后一次)
在里面
---->1从keras.layers导入点
c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site packages\keras\\uuuu init\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
4除恐怖外:
5.引起恐怖(
---->6“Keras要求TensorFlow 2.2或更高。”
7“通过“pip安装TensorFlow”安装TensorFlow”)
8.
导入错误:Keras需要TensorFlow 2.2或更高版本。通过“pip安装TensorFlow”安装TensorFlow`

我升级了tensorflow。也重新安装了它,但没有工作。

嘿,同一个问题有多个解决方案-->

  • 解决方案->1

  • 检查CUDA的环境设置,通常CUDA的所有设置都已添加到Windows环境中

  • 将cuDNN的
    bin
    lib
    include
    中的文件分别复制到CUDA的
    bin
    lib
    include
    。通常目录为
    C:\Program files\NVIDIA GPU Computing Toolkit\CUDA

  • 然后你可以导入tensorflow并运行你的代码。祝你好运

  • 解决方案->2

  • 如有必要,只需运行下面的命令,然后更新它

  • pip安装tensorflow==1.5


    • 我有CUDA 10.0和cuDNN 7.6.4 我也得到下面这个错误

      导入错误:Keras需要TensorFlow 2.2或更高版本。通过
      pip安装tenso安装TensorFlow