首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法安装OpenFST Python扩展

无法安装OpenFST Python扩展
EN

Stack Overflow用户
提问于 2018-06-25 17:32:42
回答 1查看 3.1K关注 0票数 0

根据OpenFST指南,我试图安装 Python扩展。这样做有两种选择。

第一个选择是在OpenFst配置期间发出OpenFst,我尝试了,但失败了。

所以我选择了第二个选择。我成功地用以下命令安装了OpenFST:

代码语言:javascript
复制
./configure --enable-far
make
sudo make install

然后,我尝试使用PyPi包openfst安装pip

pip install openfst

并得到以下错误:

代码语言:javascript
复制
Collecting openfst
  Using cached https://files.pythonhosted.org/packages/cc/6b/cc05392480e2232e176be895b9ca2b9f4a5f153f99ab276b37d440b3bace/openfst-1.6.6.tar.gz
Building wheels for collected packages: openfst
  Running setup.py bdist_wheel for openfst ... error
  Complete output from command /home/arif/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-7y6dl6o2/openfst/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-zadciiwk --python-tag cp36:
  running bdist_wheel
  running build
  running build_ext
  building 'pywrapfst' extension
  creating build
  creating build/temp.linux-x86_64-3.6
  gcc -pthread -B /home/arif/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/arif/anaconda3/include/python3.6m -c pywrapfst.cc -o build/temp.linux-x86_64-3.6/pywrapfst.o -std=c++11 -Wno-unneeded-internal-declaration -Wno-unused-function
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  pywrapfst.cc:557:40: fatal error: fst/extensions/far/getters.h: No such file or directory
  compilation terminated.
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for openfst
  Running setup.py clean for openfst
Failed to build openfst
Installing collected packages: openfst
  Running setup.py install for openfst ... error
    Complete output from command /home/arif/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-7y6dl6o2/openfst/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-3niypfz6/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'pywrapfst' extension
    creating build
    creating build/temp.linux-x86_64-3.6
    gcc -pthread -B /home/arif/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/arif/anaconda3/include/python3.6m -c pywrapfst.cc -o build/temp.linux-x86_64-3.6/pywrapfst.o -std=c++11 -Wno-unneeded-internal-declaration -Wno-unused-function
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    pywrapfst.cc:557:40: fatal error: fst/extensions/far/getters.h: No such file or directory
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/home/arif/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-7y6dl6o2/openfst/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-3niypfz6/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-7y6dl6o2/openfst/

有人能帮我解决这个问题吗?

我在python 3.6 (anaconda)OpenFST-1.5.4中使用Linux Mint 18.3

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-25 18:31:02

这里有两个问题。

首先,据我所知,尽管已记录在案,但pip install方法确实不受支持,甚至无法工作。凯尔·戈尔曼(我认为他是主要作者之一)在多个论坛帖子上发表了评论,回复如下:

因为这没有什么意义,而且无论如何,这已经过时了。“ “没有理由调用pip。上面的版本与任意的OpenFst版本不兼容。如果您这样做了--启用--python然后创建并制作安装,那么您已经为您正在构建的任何版本的OpenFst安装了pywrapfst。”

其次,尽管说它适用于“任何Python2.7或更高版本”,但实际上它只适用于Python2.7:

“在提交之前,您可能希望用Python扩展来测试Python 3。不幸的是,我们仍然只在Python2.7上进行开发,而且它没有在Python 3上进行测试。”

事实上,这正是您尝试使用--enable-python失败的原因:

代码语言:javascript
复制
checking for a version of Python >= '2.1.0'...   File "<string>", line 1
    import sys, string;         ver = string.split(sys.version)[0];     print ver >= '2.1.0'
                                                                        ^
SyntaxError: invalid syntax
no

他们对Python2.1或更高版本的自动good测试使用的语法在Python3中是非法的,而且它不能很好地处理错误,因此需要SyntaxError来表示您的Python2.0或更早版本,因此它会中止配置。

如果您进一步查看同一线程,用户NurL发布:

在对配置文件和Makefile进行了大量调整之后,我成功地安装了Python3的PythonExtensionforPython3。

显然我不能保证这是否行得通。

而且,除非您使用的目标与NurL完全相同,否则您将不得不阅读巨大的RUN wget命令行,将其分解为步骤,并自己执行相应的步骤。

而且可能有一些NurL没有遇到的问题,你会遇到的。(我强烈建议至少在安装之前或之后对生成的代码运行2to3,以确保它找不到任何东西。)

但是,考虑到你想要做的事情不被支持,你很可能会得到一些不受欢迎的东西。如果你不能让它为你自己工作,你可能就是不能使用这个库。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51028980

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档