简体   繁体   中英

Failed to load the native TensorFlow runtime. when running g2p-seq2seq --version

mac OS I am trying to use cmu dictionary for speech recognition. Steps I took:

python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl

pip3 show tensorflow

result:

  • Name: tensorflow
  • Version: 1.12.0
  • Summary: TensorFlow is an open source machine learning framework for everyone.
  • Home-page: https://www.tensorflow.org/
  • Author: Google Inc.
  • Author-email: opensource@google.com
  • License: Apache 2.0
  • Location: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
  • Requires: protobuf, keras-preprocessing, tensorboard, termcolor, numpy, wheel, keras-applications, six, absl-py, grpcio, gast, astor Required-by:

And then:

pip install tensor2tensor==1.5.0
export PYTHONPATH=/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages:$PYTHONPATH
g2p-seq2seq --version

Result:

Traceback (most recent call last): File "/usr/local/bin/g2p-seq2seq", line 11, in load_entry_point('g2p-seq2seq==6.2.2a0', 'console_scripts', 'g2p-seq2seq')() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/ init .py", line 487, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/ init .py", line 2728, in load_entry_point return ep.load() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/ init .py", line 2346, in load return self.resolve() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/ init .py", line 2352, in resolve module = import (self.module_name, fromlist=[' name '], level=0) File "/usr/local/lib/python2.7/site-packages/g2p_seq2seq-6.2.2a0-py2.7.egg/g2p_seq2seq/ init .py", line 24, in from g2p_seq2seq import app File "/usr/local/lib/python2.7/site-packages/g2p_seq2seq-6.2.2a0-py2.7.egg/g2p_seq2seq/app.py", line 29, in import tensorflow as tf File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/ init .py", line 24, in from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/ init .py", line 49, in from tensorflow.python import pywrap_tensorflow File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in raise ImportError(msg) ImportError: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in from tensorflow.python.pywrap_tensorflow_internal import * File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ten sorflow/python/pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): Symbol not found: __Py_FalseStruct Referenced from: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so Expected in: flat namespace in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so Failed to load the native TensorFlow runtime.

Inside pycharm IDE console,

import tensorflow as tf

gave me this:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.6 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.7 return f(*args, **kwds)


Updated:

I go to this github site and download the correct wheel (python 3.7 for mac os 10.13). And reinstall tensorflow by

pip3 install --ignore-installed --upgrade /Users/cindy/Documents/pythonworkspace/sphinxenv/tensorflow-1.12.0-cp37-cp37m-macosx_10_13_x86_64.whl --user

I create a python file tensorflow_test.py with only one line:

imoprt tensorflow as tf

The console didn't throw out errors if I execute this file.

However

 g2p-seq2seq --version

now tells me

ImportError: No module named tensorflow

What Oluwafemi Sule says in comment is right.

pip3 -V

gives me

pip 19.0.1 from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)

At the same time,

echo $PATH

gives me

/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public

As Oluwafemi Sule recommends, add

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages

to PATH variable of Mac.

re-echo PATH again:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public

Now

g2p-seq2seq --version

no longer has the ImportError: No module named tensorflow error.

(However, I still need to solve the problem of tensorflow being too old.)

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