ImportError导入张量流

时间:2019-02-07 04:37:08

标签: python tensorflow

导入tensorflow时出现错误:

import tensorflow
Traceback (most recent call last):
  File "C:\Users\Nik\AppData\Local\Programs\Python\Python37\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\Nik\AppData\Local\Programs\Python\Python37\lib\imp.py", line 297, 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\Nik\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Nik\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Nik\AppData\Local\Programs\Python\Python37\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'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Nik\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "C:\Users\Nik\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\Nik\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\Nik\AppData\Local\Programs\Python\Python37\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\Nik\AppData\Local\Programs\Python\Python37\lib\imp.py", line 297, 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\Nik\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Nik\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Nik\AppData\Local\Programs\Python\Python37\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'

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

从您追溯到no module named tensorflow的这一行开始,我得出的结论是您使用的是python 3.7,python 3.7到目前为止还不支持tensorflow,而且看起来好像您是从python 3.6升级的,在点子安装过程中不会面对<!DOCTYPE html> <html> <head> <title>Trial</title> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css"> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script> </head> <body ng-app="App"> <div class="container" > <div ng-controller="Controller"> <form name="form" ng-submit="submitComment()"> <div class="form-group"> <label for="">Author</label> <input type="text" class="form-control input-sa" name="author" ng-model="commentData.author"> </div> <div class="form-group"> <label for="">Comment</label> <input type="text" class="form-control input-sa" name="comment" ng-model="commentData.comment"> </div> <button class="btn btn-sm btn-danger">Submit</button> </form> </div> </div> <script> angular.module('commentService',[]) .factory('comment',function($http){ return{ save:function(commentData){ return $http({ method:"POST", url:'/api/comments', data:commentData }) } } }); var app = angular.module('App',['commentService']); app.controller('Controller',function($scope,Comment){ $scope.commentData={}; $scope.submitComment=function(){ Comment.save($scope.commentData); } });

到目前为止,唯一的解决方案是使用python 3.6,因此您将需要降级python或安装conda并使用python 3.6创建环境