ImportError:无法导入名称pywrap_dlopen_global_flags

时间:2018-02-16 12:00:18

标签: tensorflow virtualenv protocol-buffers keras-rl

我在硬件上尝试使用tensorflow(版本 - 发布日期最新版本)时出现以下错误 - 带操作系统的MacBookPro CPU - 双启动Ubuntu 16.04 LTS 在与Keras和keras-rl以及python 2.7的virtualenv -no-site-packages中。

...
 Using TensorFlow backend.
2018-02-15 18:55:01,909 [Thread-46   ] [hbp_nrp_cles] [CRITICAL]  Unhandled exception of type <type 'exceptions.RuntimeError'>: module compiled against API version 0xb but this version of numpy is 0xa
2018-02-15 18:55:01,909 [Thread-46   ] [hbp_nrp_cles] [ERROR]  None
Traceback (most recent call last):
  File "/home/akshay/.opt/kerasrl_venv/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 37, in <module>
    from tensorflow.python import pywrap_dlopen_global_flags
ImportError: cannot import name pywrap_dlopen_global_flags
2018-02-15 18:55:01,910 [Thread-46   ] [hbp_nrp_cles] [CRITICAL]  Unhandled exception of type <type 'exceptions.RuntimeError'>: module compiled against API version 0xb but this version of numpy is 0xa
2018-02-15 18:55:01,910 [Thread-46   ] [hbp_nrp_cles] [ERROR]  None
Traceback (most recent call last):
  File "/home/akshay/.opt/kerasrl_venv/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 37, in <module>
    from tensorflow.python import pywrap_dlopen_global_flags
ImportError: cannot import name pywrap_dlopen_global_flags
[libprotobuf FATAL external/protobuf_archive/src/google/protobuf/stubs/common.cc:68] This program requires version 3.5.0 of the Protocol Buffer runtime library, but the installed version is 3.4.0.  Please update your library.  If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library.  (Version verification failed in "google/protobuf/descriptor.pb.cc".)
terminate called after throwing an instance of 'google::protobuf::FatalException'

...

我用过

site.addsitedir(os.path.expanduser('path/to/tensorflow_venv/lib/python2.7/site-packages'))

在其他环境中工作时导入keras-rl模块

这个ImportError是什么意思?我检查了文件pwrap_tensorflow.py中的代码,并且不理解异常上方的注释。

...
try:
  # This import is expected to fail if there is an explicit shared object
  # dependency (with_framework_lib=true), since we do not need RTLD_GLOBAL.
  from tensorflow.python import pywrap_dlopen_global_flags
  _use_dlopen_global_flags = True
except ImportError:
  _use_dlopen_global_flags = False
... 

我也遇到了一个protobuf问题。 venv中的protobuf版本是3.5.1

0 个答案:

没有答案
相关问题