简体   繁体   中英

unable to import tensorflow on win10

Machine crashed last week. Trying to get tensorflow back on win10. I have tried reinstalling Anaconda3 twice already, downgraded to python36, tried tensorflow using both pip and conda but nothing seem to work. here's the error msg - any help would be greatly appreciated

    import tensorflow as tf
    import numpy as np
    from keras.models import Sequential
    from keras.layers import Dense,Activation, Dropout
    from keras.utils import to_categorical, plot_model
    from keras.datasets import mnist
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-c4ab1c6524a9> in <module>
----> 1 import tensorflow as tf
      2 import numpy as np
      3 from keras.models import Sequential
      4 from keras.layers import Dense,Activation, Dropout
      5 from keras.utils import to_categorical, plot_model

C:\Anaconda3\lib\site-packages\tensorflow\__init__.py in <module>
     32 
     33 # pylint: disable=g-bad-import-order
---> 34 from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
     35 from tensorflow.python.tools import module_util as _module_util
     36 

C:\Anaconda3\lib\site-packages\tensorflow\python\__init__.py in <module>
     50 
     51 # Protocol buffers
---> 52 from tensorflow.core.framework.graph_pb2 import *
     53 from tensorflow.core.framework.node_def_pb2 import *
     54 from tensorflow.core.framework.summary_pb2 import *

C:\Anaconda3\lib\site-packages\tensorflow\core\framework\graph_pb2.py in <module>
     14 
     15 
---> 16 from tensorflow.core.framework import node_def_pb2 as tensorflow_dot_core_dot_framework_dot_node__def__pb2
     17 from tensorflow.core.framework import function_pb2 as tensorflow_dot_core_dot_framework_dot_function__pb2
     18 from tensorflow.core.framework import versions_pb2 as tensorflow_dot_core_dot_framework_dot_versions__pb2

C:\Anaconda3\lib\site-packages\tensorflow\core\framework\node_def_pb2.py in <module>
     14 
     15 
---> 16 from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
     17 
     18 

C:\Anaconda3\lib\site-packages\tensorflow\core\framework\attr_value_pb2.py in <module>
     14 
     15 
---> 16 from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
     17 from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
     18 from tensorflow.core.framework import types_pb2 as tensorflow_dot_core_dot_framework_dot_types__pb2

C:\Anaconda3\lib\site-packages\tensorflow\core\framework\tensor_pb2.py in <module>
     14 
     15 
---> 16 from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
     17 from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
     18 from tensorflow.core.framework import types_pb2 as tensorflow_dot_core_dot_framework_dot_types__pb2

C:\Anaconda3\lib\site-packages\tensorflow\core\framework\resource_handle_pb2.py in <module>
     90 ResourceHandleProto = _reflection.GeneratedProtocolMessageType('ResourceHandleProto', (_message.Message,), dict(
     91   DESCRIPTOR = _RESOURCEHANDLEPROTO,
---> 92   __module__ = 'tensorflow.core.framework.resource_handle_pb2'
     93   # @@protoc_insertion_point(class_scope:tensorflow.ResourceHandleProto)
     94   ))

TypeError: expected bytes, Descriptor found

Resolved. Turns out the VC++ redist(x64) was missing. it is a painful task recreating the environment if the machine crashes. It would be helpful if tensorflow install dealt with vc++ redist dependency as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM