1

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

注意:候选人需要 16 个参数,提供 15 个参数 错误:命令“x86_64-linux-gnu-gcc”失败,退出状态为 1

并且还尝试了@PyFST Setup OGI,但失败了

`

错误:命令“x86_64-linux-gnu-gcc”失败,退出状态为 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

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

/usr/local/include/fst/float-weight.h:在 'static const fst::MinMaxWeightTpl& fst::MinMaxWeightTpl::NoWeight() [with T = float]'的实例化中:/usr/local/include/fst /float-weight.h:615:72: 来自 'fst::MinMaxWeightTpl fst::Plus(const fst::MinMaxWeightTpl&, const fst::MinMaxWeightTpl&) [with T = float]' /usr/local/include/fst /float-weight.h:621:28:从这里需要 /usr/local/include/fst/float-weight.h:576:69:错误:'NumberBad' 不是'fst::FloatLimits'静态的成员const MinMaxWeightTpl no_weight(FloatLimits::NumberBad()); ^ /usr/local/include/fst/float-weight.h: 在 'static const fst::MinMaxWeightTpl& fst::MinMaxWeightTpl::NoWeight() [with T = double]' 的实例化中:

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

命令“/usr/bin/python -u -c”导入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" 失败,错误代码 1 在 /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/前缀

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解决demo.clab.cs.cmu.edu ( demo.clab.cs.cmu.edu)... 128.2.220.95 正在连接到 demo.clab.cs.cmu.edu (demo.clab.cs.cmu.edu)|128.2.220.95|:80... 已连接。HTTP 请求已发送,等待响应... 200 OK 长度:148781 (145K) [application/x-gzip] 保存到:'pyfst-0.2.5.tar.gz.1'</p>

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

2017-05-21 18:37:34 (720 KB/s) - 'pyfst-0.2.5.tar.gz.1' 已保存 [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-别名 -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:警告:命令行选项“-Wstrict-prototypes”对 C/ObjC 有效,但对 C++ fst/_fst.cpp 无效:在函数中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,双,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);^ 在来自 /usr/local/include/fst/script/draw.h:10:0 的文件中,来自 fst/_fst.cpp:242: /usr/local/include/fst/script/draw-impl.h: 29:3:注意:候选: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::isyms, ^ /usr/local/include/fst/script/draw-impl.h:29:3: 注意:候选人需要 16 个参数,提供 15 个 fst/_fst.cpp:在函数 '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); ^ 在来自 /usr/local/include/fst/script/draw.h:10:0 的文件中,来自 fst/_fst.cpp:242: /usr/local/include/fst/script/draw-impl.h: 29:3:注意:候选人: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: 注意:候选人需要 16 个参数,提供 15 个错误:命令“x86_64-linux-gnu-gcc”失败,退出状态为 1

4

1 回答 1

1

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

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

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

OpenFST 网站上提供了一些附加信息。

于 2017-05-23T04:54:46.570 回答