简体   繁体   中英

Recieving error when importing tensorflow

I've been trying to import TensorFlow but I keep receiving this error. I've looked through many chat rooms but for some reason, those answers are not working on my system, am I missing something.

import tensorflow as tf
RuntimeError                              Traceback (most recent call last)
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
ImportError: numpy.core.multiarray failed to import

The above exception was the direct cause of the following exception:

SystemError                               Traceback (most recent call last)
SystemError: <built-in method __contains__ of dict object at 0x7ff0375b55a0> returned a result with an error set

The above exception was the direct cause of the following exception:

ImportError                               Traceback (most recent call last)
<ipython-input-102-64156d691fe5> in <module>
----> 1 import tensorflow as tf

~/opt/anaconda3/lib/python3.7/site-packages/tensorflow/__init__.py in <module>
     39 import sys as _sys
     40 
---> 41 from tensorflow.python.tools import module_util as _module_util
     42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
     43 

~/opt/anaconda3/lib/python3.7/site-packages/tensorflow/python/__init__.py in <module>
     39 
     40 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
---> 41 from tensorflow.python.eager import context
     42 
     43 # pylint: enable=wildcard-import

~/opt/anaconda3/lib/python3.7/site-packages/tensorflow/python/eager/context.py in <module>
     36 from tensorflow.python import pywrap_tfe
     37 from tensorflow.python import tf2
---> 38 from tensorflow.python.client import pywrap_tf_session
     39 from tensorflow.python.eager import executor
     40 from tensorflow.python.eager import monitoring

~/opt/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/pywrap_tf_session.py in <module>
     21 # pylint: disable=invalid-import-order,g-bad-import-order, wildcard-import, unused-import
     22 from tensorflow.python import pywrap_tensorflow
---> 23 from tensorflow.python.client._pywrap_tf_session import *
     24 from tensorflow.python.client._pywrap_tf_session import _TF_SetTarget
     25 from tensorflow.python.client._pywrap_tf_session import _TF_SetConfig

ImportError: initialization failed```

**Here are my dependency versions, in case:**
tensorboard                        2.8.0
tensorboard-data-server            0.6.1
tensorboard-plugin-wit             1.8.1
tensorflow                         2.7.0
tensorflow-estimator               2.7.0
tensorflow-hub                     0.12.0
tensorflow-io-gcs-filesystem       0.26.0
tensorflow-text                    2.9.0
numpy                              1.21.5
numpy-financial                    1.0.0
numpydoc                           0.9.1

Please check that your workstation qualifies for hardware requirements of tensorflow. these are the hardware requirements . Secondly check whether your installation copy of python is added to path as it may run into problem while pip installing the module which are required. Once done, please check the version of tensorflow which is compatible for your workstation and the python versiopn.

Regards

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