With Python 2.7.12 and Ubuntu 16.04.2 LTS, I tried following instructions @ PyFST Setup CMU to install OpenFst and pyfst but fails with error
note: candidate expects 16 arguments, 15 provided error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
and also tried @ PyFST Setup OGI but fails with
`
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Looks like OpenFst is setup properly because I am able to see fst commands.
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
However, I get this error when I try to run sudo pip install pyfst
...(only including a snippet of the error message because longer than the terminal 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/
Or I try the following:
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
Which appears to work fine
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
Don't use PyFST, it's out of date. Python bindings are included with OpenFST since approximately version 1.5.1. Just install OpenFST as normal, with the
--enable-python
:That should put the Python libraries in the appropriate places.
Some additional information is available on the OpenFST website.