安装pocketsphinx python 模块:命令'swig.exe' 失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44504899/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing pocketsphinx python module: command 'swig.exe' failed
提问by Krushi Raj
I'm getting something like this. Can anyone please tell me how to fix this.
我得到这样的东西。谁能告诉我如何解决这个问题。
C:\Users\krush\Documents\ML using Python>pip install pocketsphinx
Collecting pocketsphinx
Using cached pocketsphinx-0.1.3.zip
Building wheels for collected packages: pocketsphinx
Running setup.py bdist_wheel for pocketsphinx: started
Running setup.py bdist_wheel for pocketsphinx: finished with status 'error'
Complete output from command C:\Users\krush\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\krush\AppData\Local\Temp\pip-build-cns2i_wb\pocketsphinx\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 C:\Users\krush\AppData\Local\Temp\tmp3tyvnl9wpip-wheel- --python-tag cp36:
running bdist_wheel
running build_ext
building 'sphinxbase._ad' extension
swigging swig/sphinxbase/ad.i to swig/sphinxbase/ad_wrap.c
swig.exe -python -modern -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/win32 -Ideps/sphinxbase/swig -outdir sphinxbase -o swig/sphinxbase/ad_wrap.c swig/sphinxbase/ad.i
error: command 'swig.exe' failed: No such file or directory
----------------------------------------
Failed building wheel for pocketsphinx
Running setup.py clean for pocketsphinx
Failed to build pocketsphinx
Installing collected packages: pocketsphinx
Running setup.py install for pocketsphinx: started
Running setup.py install for pocketsphinx: finished with status 'error'
Complete output from command C:\Users\krush\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\krush\AppData\Local\Temp\pip-build-cns2i_wb\pocketsphinx\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\krush\AppData\Local\Temp\pip-x5mxeczy-record\install-record.txt --single-version-externally-managed --compile:
running install
running build_ext
building 'sphinxbase._ad' extension
swigging swig/sphinxbase/ad.i to swig/sphinxbase/ad_wrap.c
swig.exe -python -modern -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/win32 -Ideps/sphinxbase/swig -outdir sphinxbase -o swig/sphinxbase/ad_wrap.c swig/sphinxbase/ad.i
error: command 'swig.exe' failed: No such file or directory
----------------------------------------
Command "C:\Users\krush\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\krush\AppData\Local\Temp\pip-build-cns2i_wb\pocketsphinx\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\krush\AppData\Local\Temp\pip-x5mxeczy-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\krush\AppData\Local\Temp\pip-build-cns2i_wb\pocketsphinx\
回答by Mohamed El Shenawy
To fix the problem, I downloaded swig for windows
为了解决这个问题,我下载了swig for windows
Copy swig.exe to the python installation folder (for ex C:/python27)
Open swigwin-3.0.12/Lib folder and copy all *.swg files to the C:/python27/lib or equivalent python path
Open swigwin-3.0.12/lib/python and copy all the files to (C:/python27/lib)
将 swig.exe 复制到 python 安装文件夹(例如 C:/python27)
打开 swigwin-3.0.12/Lib 文件夹并将所有 *.swg 文件复制到 C:/python27/lib 或等效的 python 路径
打开 swigwin-3.0.12/lib/python 并将所有文件复制到 (C:/python27/lib)
(Also make sure you have Microsoft Visual C++ Compiler for Python installed)
(还要确保您安装了 Microsoft Visual C++ Compiler for Python)
These steps worked for me.
这些步骤对我有用。
回答by Guillaume Jacquenot
You try to install pocketsphinx
with pip
, that will download and compile this module. It requires some compiling tool like swig
.
您尝试安装pocketsphinx
使用pip
,这将下载并编译这个模块。它需要一些编译工具,如swig
.
Another solution is to install a binary version of pocketsphinx
. You can download a binary version here. You have to select the correct version with respect to your installation.
另一种解决方案是安装二进制版本的pocketsphinx
. 您可以在此处下载二进制版本。您必须根据安装选择正确的版本。
To determine which one you have to download, you can run the following commands, that will tell you which version you require and whether you run a 32 or 64 bit python interpreter.
要确定您必须下载哪个,您可以运行以下命令,它会告诉您需要哪个版本以及您运行的是 32 位还是 64 位 python 解释器。
"C:\Users\krush\Anaconda3\python.exe" --version
"C:\Users\krush\Anaconda3\python.exe" -c "import struct;print(struct.calcsize('P') * 8)"
Below are some commands that you may enter once you have downloaded the correct version
以下是您下载正确版本后可以输入的一些命令
"C:\Users\krush\Anaconda3\python.exe" -m pip install pocketsphinx?0.1.3?cp35?cp35m?win32.whl
"C:\Users\krush\Anaconda3\python.exe" -m pip install pocketsphinx?0.1.3?cp36?cp36m?win_amd64.whl
回答by W Barreto
Instead of copying Swig files to the Python folder, you can simply add Swig`s location to the environment variables:
无需将 Swig 文件复制到 Python 文件夹,您只需将 Swig 的位置添加到环境变量中即可:
- Press
Ctrl+S
- Type
env
and pressEnter
- Double click on
Path
- Add the path-to-Swigto the last blank line
- Click
OK
and restart your PC
- 按
Ctrl+S
- 输入
env
并按下Enter
- 双击
Path
- 将Swig的路径添加到最后一个空行
- 单击
OK
并重新启动您的 PC
回答by Jaideep Heer
conda install swig
pip install pocketsphinx
I didn't want to do all that setup other people are suggesting so I tried this and it worked. This probably only works if you are using Anaconada though.
我不想做其他人建议的所有设置,所以我尝试了这个并且它起作用了。不过,这可能仅在您使用 Anaconada 时才有效。
回答by Ramesh Kumar
I was also getting same error, while installing in ubuntu 16.04, I executed following commands:
我也遇到了同样的错误,在 ubuntu 16.04 中安装时,我执行了以下命令:
sudo apt-get install -y python python-dev python-pip build-essential swig git libpulse-dev
sudo pip install pocketsphinx
source: pocketsphinx-python
回答by ambar mishra
In case you are working on anaconda navigator.
Just go to environment.
Search swig, your package will be displayed. Select the package and click on apply button.
It will also give a prompt list of other dependencies, which need to be installed with swig.
So just select all and click on apply button.
All the dependencies will be installed in your root directory of anaconda.
如果您正在使用 anaconda 导航器。
只是去环境。
搜索 swig,你的包裹就会显示出来。选择包并单击应用按钮。它还会给出其他依赖项的提示列表,这些依赖项需要用 swig 安装。
所以只需全选并单击应用按钮。
所有依赖项都将安装在 anaconda 的根目录中。
This worked for me, hope it helps.
这对我有用,希望它有所帮助。
回答by Nitish nagar
There are few set of commands to resolve this. Just execute them:
很少有一组命令可以解决这个问题。只需执行它们:
sudo apt-get install -y python3 python3-dev python3-pip build-essential swig git libpulse-dev
sudo apt-get install libasound2-dev
sudo pip install pocketsphinx