PyFst 安装 Ubuntu 错误命令 'x86_64-linux-gnu-gcc' 失败,退出状态为 1

PyFst Install Ubuntu Error Command 'x86_64-linux-gnu-gcc' failed with exit status 1

使用 Python 2.7.12 和 Ubuntu 16.04.2 LTS,我尝试按照说明 @ PyFST Setup CMU 安装 OpenFst 和 pyfst 但失败并出现错误

note: candidate expects 16 arguments, 15 provided error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

也试过@PyFST Setup OGI但失败了

`

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

看起来 OpenFst 设置正确,因为我能够看到 fst 命令。

wilson@wilson-300V3A-300V4A-300V5A:~/demo/openfst-1.6.2$ ls ~/prefix/bin

fstarcsort fstencode fstprune fstsynchronize fstclosure fstepsnormalize fstpush fsttopsort fstcompile fstequal fstrandgen fstunion fstcompose fstequivalent fstrelabel pdtcompose fstconcat fstinfo fstreplace pdtexpand fstconnect fstintersect fstreverse pdtinfo fstconvert fstinvert fstreweight pdtreplace fstdeterminize fstmap fstrmepsilon pdtreverse fstdifference fstminimize fstshortestdistance pdtshortestpath fstdisambiguate fstprint fstshortestpath fstdraw
fstproject fstsymbols

但是,当我尝试 运行 sudo pip install pyfst

时出现此错误

...(仅包括错误消息的片段,因为比终端 window 长)

/usr/local/include/fst/float-weight.h: In instantiation of ‘static const fst::MinMaxWeightTpl& fst::MinMaxWeightTpl::NoWeight() [with T = float]’: /usr/local/include/fst/float-weight.h:615:72: required from ‘fst::MinMaxWeightTpl fst::Plus(const fst::MinMaxWeightTpl&, const fst::MinMaxWeightTpl&) [with T = float]’ /usr/local/include/fst/float-weight.h:621:28: required from here /usr/local/include/fst/float-weight.h:576:69: error: ‘NumberBad’ is not a member of ‘fst::FloatLimits’ static const MinMaxWeightTpl no_weight(FloatLimits::NumberBad()); ^ /usr/local/include/fst/float-weight.h: In instantiation of ‘static const fst::MinMaxWeightTpl& fst::MinMaxWeightTpl::NoWeight() [with T = double]’: /usr/local/include/fst/float-weight.h:615:72: required from ‘fst::MinMaxWeightTpl fst::Plus(const fst::MinMaxWeightTpl&, const fst::MinMaxWeightTpl&) [with T = double]’ /usr/local/include/fst/float-weight.h:626:29: required from here /usr/local/include/fst/float-weight.h:576:69: error: ‘NumberBad’ is not a member of ‘fst::FloatLimits’ error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------

Command "/usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-DngJ9w/pyfst/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-FFhvRI-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-DngJ9w/pyfst/

或者我尝试以下操作:

wilson@wilson-300V3A-300V4A-300V5A:~/demo/openfst-1.6.2$ echo "export PREFIX=$(cd; pwd)/prefix" >> ~/.bashrc
wilson@wilson-300V3A-300V4A-300V5A:~/demo/openfst-1.6.2$ 
wilson@wilson-300V3A-300V4A-300V5A:~/demo/openfst-1.6.2$ echo 'export CPLUS_INCLUDE_PATH=$PREFIX/include:$CPLUS_INCLUDE_PATH
> export LIBRARY_PATH=$PREFIX/lib:$LIBRARY_PATH
> export LIBRARY_PATH=$PREFIX/lib/fst:$LIBRARY_PATH
> export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH
> export LD_LIBRARY_PATH=$PREFIX/lib/fst:$LD_LIBRARY_PATH
> export PATH=$PREFIX/bin:$PATH
> export PYTHONPATH=$PREFIX/lib/python2.7/site-packages:$PYTHONPATH' >> ~/.bashrc

这似乎工作正常

wilson@wilson-300V3A-300V4A-300V5A:~/demo/openfst-1.6.2$ echo $PREFIX

/home/wilson/prefix

wilson@wilson-300V3A-300V4A-300V5A:~/demo/openfst-1.6.2$ cd $PREFIX
wilson@wilson-300V3A-300V4A-300V5A:~/prefix$ wget http://demo.clab.cs.cmu.edu/cdyer/pyfst-0.2.5.tar.gz

--2017-05-21 18:37:34-- http://demo.clab.cs.cmu.edu/cdyer/pyfst-0.2.5.tar.gz Resolving demo.clab.cs.cmu.edu (demo.clab.cs.cmu.edu)... 128.2.220.95 Connecting to demo.clab.cs.cmu.edu (demo.clab.cs.cmu.edu)|128.2.220.95|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 148781 (145K) [application/x-gzip] Saving to: ‘pyfst-0.2.5.tar.gz.1’

pyfst-0.2.5.tar.gz. 100%[===================>] 145.29K 720KB/s in 0.2s

2017-05-21 18:37:34 (720 KB/s) - ‘pyfst-0.2.5.tar.gz.1’ saved [148781/148781]

wilson@wilson-300V3A-300V4A-300V5A:~/prefix$ tar xzf pyfst-0.2.5.tar.gz
wilson@wilson-300V3A-300V4A-300V5A:~/prefix$ cd pyfst-0.2.5/
wilson@wilson-300V3A-300V4A-300V5A:~/prefix/pyfst-0.2.5$ python setup.py 

install --prefix=$PREFIX running install running build running build_py running build_ext building 'fst._fst' extension x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c fst/_fst.cpp -o build/temp.linux-x86_64-2.7/fst/_fst.o -std=c++11 cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ fst/_fst.cpp: In function ‘PyObject* __pyx_pf_3fst_4_fst_12StdVectorFst_120draw(__pyx_obj_3fst_4_fst_StdVectorFst*, __pyx_obj_3fst_4_fst_SymbolTable*, __pyx_obj_3fst_4_fst_SymbolTable*, __pyx_obj_3fst_4_fst_SymbolTable*)’: fst/_fst.cpp:17681:191: error: no matching function for call to ‘fst::FstDrawer >

::FstDrawer(fst::StdVectorFst&, fst::SymbolTable*&, fst::SymbolTable*&, fst::SymbolTable*&, int, std::__cxx11::string&, double, double, int, int, double, double, int, int, int)’ ble, __pyx_v_ssyms_table, 0, __pyx_t_5, 8.5, 11.0, 1, 0, 0.40, 0.25, 14, 5, 0); ^ In file included from /usr/local/include/fst/script/draw.h:10:0, from fst/_fst.cpp:242: /usr/local/include/fst/script/draw-impl.h:29:3: note: candidate: fst::FstDrawer::FstDrawer(const fst::Fst&, const fst::SymbolTable*, const fst::SymbolTable*, const fst::SymbolTable*, bool, const string&, float, float, bool, bool, float, float, int, int, const string&, bool) [with Arc = fst::ArcTpl >; std::__cxx11::string = std::__cxx11::basic_string] FstDrawer(const Fst &fst, const SymbolTable isyms, ^ /usr/local/include/fst/script/draw-impl.h:29:3: note: candidate expects 16 arguments, 15 provided fst/_fst.cpp: In function ‘PyObject __pyx_pf_3fst_4_fst_12LogVectorFst_120draw(__pyx_obj_3fst_4_fst_LogVectorFst*, __pyx_obj_3fst_4_fst_SymbolTable*, __pyx_obj_3fst_4_fst_SymbolTable*, __pyx_obj_3fst_4_fst_SymbolTable*)’: fst/_fst.cpp:30639:191: error: no matching function for call to ‘fst::FstDrawer > ::FstDrawer(fst::VectorFst > >&, fst::SymbolTable*&, fst::SymbolTable*&, fst::SymbolTable*&, int, std::__cxx11::string&, double, double, int, int, double, double, int, int, int)’ ble, __pyx_v_ssyms_table, 0, __pyx_t_5, 8.5, 11.0, 1, 0, 0.40, 0.25, 14, 5, 0); ^ In file included from /usr/local/include/fst/script/draw.h:10:0, from fst/_fst.cpp:242: /usr/local/include/fst/script/draw-impl.h:29:3: note: candidate: fst::FstDrawer::FstDrawer(const fst::Fst&, const fst::SymbolTable*, const fst::SymbolTable*, const fst::SymbolTable*, bool, const string&, float, float, bool, bool, float, float, int, int, const string&, bool) [with Arc = fst::ArcTpl ; std::__cxx11::string = std::__cxx11::basic_string] FstDrawer(const Fst &fst, const SymbolTable *isyms, ^ /usr/local/include/fst/script/draw-impl.h:29:3: note: candidate expects 16 arguments, 15 provided error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

不要使用 PyFST,它已经过时了。 Python 从大约 1.5.1 版开始,绑定就包含在 OpenFST 中。只需正常安装 OpenFST,使用 --enable-python:

./configure --enable-python
make
sudo make install

应该将 Python 库放在适当的位置。

一些附加信息可用 on the OpenFST website