无法加载本地TensorFlow运行时。运行g2p-seq2seq --version

时间:2019-02-03 01:32:04

标签: python tensorflow pycharm pocketsphinx

mac OS 我正在尝试使用cmu词典进行语音识别。 我采取的步骤:

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

pip3 show tensorflow

结果:

  
      
  • 名称:tensorflow
  •   
  • 版本:1.12.0
  •   
  • 摘要:TensorFlow是面向所有人的开源机器学习框架。
  •   
  • 主页:https://www.tensorflow.org/
  •   
  • 作者:Google Inc。
  •   
  • 作者电子邮件:opensource@google.com
  •   
  • 许可证:Apache 2.0
  •   
  • 位置:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
  •   
  • 需求:protobuf,keras预处理,张量板,termcolor,numpy,wheel,keras应用程序,六,absl-py,grpcio,gast,astor   必填者:
  •   

然后:

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

结果:

  

回溯(最近通话最近):     在第11行的文件“ / usr / local / bin / g2p-seq2seq”       load_entry_point('g2p-seq2seq == 6.2.2a0','console_scripts','g2p-seq2seq')()     文件“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/init.py”,第487行,位于load_entry_point       返回get_distribution(dist).load_entry_point(组名)     文件“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/init.py”,第2728行,位于load_entry_point       返回ep.load()     载入中的文件“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/init.py”,行2346       返回self.resolve()     解析文件“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/init.py”,行2352       module = 导入(self.module_name,fromlist = ['名称'],级别= 0)     在第24行中输入文件“ /usr/local/lib/python2.7/site-packages/g2p_seq2seq-6.2.2a0-py2.7.egg/g2p_seq2seq/init.py”       从g2p_seq2seq导入应用程序     在第29行中输入“ /usr/local/lib/python2.7/site-packages/g2p_seq2seq-6.2.2a0-py2.7.egg/g2p_seq2seq/app.py”       将tensorflow作为tf导入     在第24行的文件“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/init.py”中       从tensorflow.python import pywrap_tensorflow#pylint:disable = unused-import     在第49行的“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/init.py”文件中       从tensorflow.python导入pywrap_tensorflow     文件“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py”,第74行,在       提高ImportError(msg)   ImportError:追溯(最近一次呼叫最近):     在第58行的“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py”文件中       从tensorflow.python.pywrap_tensorflow_internal导入*     在第28行的“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py”文件中       _pywrap_tensorflow_internal = swig_import_helper()     swig_import_helper中的第24行,文件“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py”       _mod = imp.load_module('_ pywrap_tensorflow_internal',fp,路径名,描述)   ImportError:dlopen(/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so,6):找不到符号:__Py_FalseStruct     引用自:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so     预期于:平面名称空间    在/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so中   无法加载本机TensorFlow运行时。

在pycharm IDE控制台内部,

import tensorflow as tf

给我这个:

  

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/_bootstrap.py:219:RuntimeWarning:模块'tensorflow.python.framework.fast_tensor_util'的编译时版本3.6与运行时不匹配版本3.7     返回f(* args,** kwds)

     

已更新:

我转到此github site并下载正确的滚轮(对于Mac OS 10.13,为python 3.7)。 并通过

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

我仅用一行创建一个python文件 tensorflow_test.py

imoprt tensorflow as tf

如果执行此文件,控制台不会抛出错误。

但是

 g2p-seq2seq --version

现在告诉我

  

ImportError:没有名为tensorflow的模块

1 个答案:

答案 0 :(得分:0)

Oluwafemi Sule在评论中说的是正确的。

pip3 -V

给我

  来自/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip(python 3.7)的

pip 19.0.1

同时,

echo $PATH

给我

  

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

按照Oluwafemi Sule的建议, 添加

  

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

到Mac的 PATH 变量。

再次重回路径:

  

/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

现在

g2p-seq2seq --version

不再出现 ImportError:No module named tensorflow 错误。

(但是,我仍然需要解决张量流太旧的问题。)