无法安装 OpenFST Python 扩展
Unable to install OpenFST Python extension
我试图根据 this 指南安装 OpenFST Python 扩展。这样做有两种选择。
第一个选项是在配置 OpenFst 期间发出 --enable-python
,我尝试过但失败了。
所以我选择了第二个选项。我使用这些命令成功安装了 OpenFST:
./configure --enable-far
make
sudo make install
然后我尝试用 pip
安装 PyPi 包 openfst
:
pip install openfst
并收到以下错误:
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/
谁能帮我解决这个问题?
我在 Linux Mint 18.3
中使用 python 3.6 (anaconda)
和 OpenFST-1.5.4
。
这里有两个问题。
首先,据我所知,尽管有记录,pip install
方法确实不受支持,甚至预计不会起作用。 Kyle Gorman(我认为他是主要作者之一)在多个论坛主题上发表了评论,回复如下:
"Using pip
for this doesn't make much sense, and that's out of date anyways."
其次,尽管说它适用于“任何 Python 2.7 或更高版本”,但实际上它只适用于 Python 2.7:
事实上,这正是您尝试使用 --enable-python
失败的原因:
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
他们对 Python 2.1 或更高版本的 autoconf 测试使用的语法在 Python 3 中是非法的。而且它没有很好的错误处理,所以需要 SyntaxError
这意味着您的 Python 是 2.0 或更早版本,因此它会中止配置。
如果您进一步查看同一主题,用户 NurL 发布了:
After a lot of tweaks to the configuration file and Makefile I managed to successfully install the Python extension for Python 3. See this Dockerfile: https://gist.github.com/0xnurl/6f97eb39409ea48db31fe315fd1e208f
我显然不能保证这是否有效。
而且,除非您使用与 NurL 完全相同的目标,否则您将不得不通读那个巨大的 RUN wget
命令行,将其分解成多个步骤,然后自己执行等效的步骤。
可能有 NurL 没有 运行 解决的问题,您会解决的。 (我强烈建议在安装之前或之后至少 运行ning 2to3
处理结果代码,以确保它找不到任何东西。)
但这与您可能获得开箱即用的东西一样接近,因为您尝试做的事情不受支持。如果你不能从那里让它自己工作,你可能就是不能使用这个库。
我试图根据 this 指南安装 OpenFST Python 扩展。这样做有两种选择。
第一个选项是在配置 OpenFst 期间发出 --enable-python
,我尝试过但失败了。
所以我选择了第二个选项。我使用这些命令成功安装了 OpenFST:
./configure --enable-far
make
sudo make install
然后我尝试用 pip
安装 PyPi 包 openfst
:
pip install openfst
并收到以下错误:
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/
谁能帮我解决这个问题?
我在 Linux Mint 18.3
中使用 python 3.6 (anaconda)
和 OpenFST-1.5.4
。
这里有两个问题。
首先,据我所知,尽管有记录,pip install
方法确实不受支持,甚至预计不会起作用。 Kyle Gorman(我认为他是主要作者之一)在多个论坛主题上发表了评论,回复如下:
"Using
pip
for this doesn't make much sense, and that's out of date anyways."
其次,尽管说它适用于“任何 Python 2.7 或更高版本”,但实际上它只适用于 Python 2.7:
事实上,这正是您尝试使用 --enable-python
失败的原因:
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
他们对 Python 2.1 或更高版本的 autoconf 测试使用的语法在 Python 3 中是非法的。而且它没有很好的错误处理,所以需要 SyntaxError
这意味着您的 Python 是 2.0 或更早版本,因此它会中止配置。
如果您进一步查看同一主题,用户 NurL 发布了:
After a lot of tweaks to the configuration file and Makefile I managed to successfully install the Python extension for Python 3. See this Dockerfile: https://gist.github.com/0xnurl/6f97eb39409ea48db31fe315fd1e208f
我显然不能保证这是否有效。
而且,除非您使用与 NurL 完全相同的目标,否则您将不得不通读那个巨大的 RUN wget
命令行,将其分解成多个步骤,然后自己执行等效的步骤。
可能有 NurL 没有 运行 解决的问题,您会解决的。 (我强烈建议在安装之前或之后至少 运行ning 2to3
处理结果代码,以确保它找不到任何东西。)
但这与您可能获得开箱即用的东西一样接近,因为您尝试做的事情不受支持。如果你不能从那里让它自己工作,你可能就是不能使用这个库。