无法在 Mac OS X Yosemite 上安装 openfst Python 库

5

我最近一周一直在尝试安装openfst的Python库,但是遇到了困难。我已经阅读了堆栈溢出和其他网站上所有类似问题的讨论,但是没有一条指导可以解决我的问题。 我已经安装了最新版本的Xcode。

brew install openfst

我还安装了openfst,但当我想通过写入以下内容来安装Python库时:

pip install openfst

在终端中,我得到:

Collecting openfst
  Using cached openfst-1.5.0.tar.gz
Building wheels for collected packages: openfst
  Running setup.py bdist_wheel for openfst
  Complete output from command /Users/ali/anaconda/bin/python -c "import setuptools;__file__='/private/var/folders/36/0m4j84pd49l55mvcqmbqt3z00000gn/T/pip-build-Jqe8Nu/openfst/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /var/folders/36/0m4j84pd49l55mvcqmbqt3z00000gn/T/tmpFNyllkpip-wheel-:
  running bdist_wheel
  running build
  running build_ext
  building 'fst' extension
  creating build
  creating build/temp.macosx-10.5-x86_64-2.7
  gcc -fno-strict-aliasing -I/Users/ali/anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/ali/anaconda/include/python2.7 -c fst.cc -o build/temp.macosx-10.5-x86_64-2.7/fst.o -std=c++11 -Wno-unneeded-internal-declaration -Wno-unused-function
  In file included from fst.cc:241:
  /usr/local/include/fst/util.h:24:10: fatal error: 'unordered_map' file not found
  #include <unordered_map>
           ^
  1 error generated.
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for openfst
Failed to build openfst
Installing collected packages: openfst
  Running setup.py install for openfst
    Complete output from command /Users/ali/anaconda/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/36/0m4j84pd49l55mvcqmbqt3z00000gn/T/pip-build-Jqe8Nu/openfst/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/36/0m4j84pd49l55mvcqmbqt3z00000gn/T/pip-oi7XrR-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'fst' extension
    gcc -fno-strict-aliasing -I/Users/ali/anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/ali/anaconda/include/python2.7 -c fst.cc -o build/temp.macosx-10.5-x86_64-2.7/fst.o -std=c++11 -Wno-unneeded-internal-declaration -Wno-unused-function
    In file included from fst.cc:241:
    /usr/local/include/fst/util.h:24:10: fatal error: 'unordered_map' file not found
    #include <unordered_map>
             ^
    1 error generated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/Users/ali/anaconda/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/36/0m4j84pd49l55mvcqmbqt3z00000gn/T/pip-build-Jqe8Nu/openfst/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/36/0m4j84pd49l55mvcqmbqt3z00000gn/T/pip-oi7XrR-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/36/0m4j84pd49l55mvcqmbqt3z00000gn/T/pip-build-Jqe8Nu/openfst

请问有人可以帮助我吗?

1个回答

3
我建议您从源代码编译OpenFST,并启用Python。这很容易:
wget http://www.openfst.org/twiki/pub/FST/FstDownload/openfst-1.7.2.tar.gz
tar zxvf openfst-1.7.2.tar.gz
cd openfst-1.7.2
./configure --enable-python
make
sudo make install

这对我有用,谢谢,不过最新版本现在是 openfst-1.7.2,链接是http://www.openfst.org/twiki/pub/FST/FstDownload/openfst-1.7.2.tar.gz - james-see
1
感谢@jamescampbell。我已将答案中的版本号更新为1.7.2。未来尝试此操作的人可能还想用最新版本替换1.7.2。 - blambert

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接