Installing pocketsphinx python module: command 'swig.exe' failed

时间:2017-06-12 16:59:06

标签: python swig pocketsphinx

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\

8 个答案:

答案 0 :(得分:7)

要解决此问题,我下载了swig for windows

  1. 将swig.exe复制到python安装文件夹(对于ex C:/ python27)

  2. 打开swigwin-3.0.12 / Lib文件夹并将所有* .swg文件复制到C:/ python27 / lib或等效的python路径

  3. 打开swigwin-3.0.12 / lib / python并将所有文件复制到(C:/ python27 / lib)

  4. (还要确保安装了Microsoft Visual C ++ Compiler for Python)

    这些步骤对我有用。

答案 1 :(得分:6)

您尝试使用pocketsphinx安装pip,这将下载并编译此模块。它需要一些编译工具,如swig

另一种解决方案是安装pocketsphinx的二进制版本。您可以下载二进制版本here。您必须根据安装选择正确的版本。

要确定您必须下载哪一个,您可以运行以下命令,它们将告诉您需要哪个版本以及是否运行32位或64位python解释器。

"C:\Users\krush\Anaconda3\python.exe" --version
"C:\Users\krush\Anaconda3\python.exe" -c "import struct;print(struct.calcsize('P') * 8)"

以下是您下载正确版本后可以输入的一些命令

"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

答案 2 :(得分:4)

conda install swig
pip install pocketsphinx

我不想做其他人建议的所有设置,所以我尝试了一下,并且奏效了。 不过,这可能仅在使用Anaconada的情况下有效。

答案 3 :(得分:2)

如果您正在使用anaconda导航器。
只是去环境。
搜索时,将显示您的包裹。选择软件包,然后单击“应用”按钮。 它还会给出其他依赖项的提示列表,需要使用swig安装。
因此,只需选择全部,然后单击“应用”按钮。
所有依赖项都将安装在anaconda的根目录中。

这对我有用,希望对您有所帮助。

答案 4 :(得分:1)

在ubuntu 16.04中安装时,我也遇到了同样的错误,我执行了以下命令:

sudo apt-get install -y python python-dev python-pip build-essential swig git libpulse-dev

sudo pip install pocketsphinx

来源:pocketsphinx-python

答案 5 :(得分:0)

几乎没有命令集可以解决此问题。只需执行它们:

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

答案 6 :(得分:0)

对我有效的方法是从conda和

conda install swing

如果已安装,则搜索安装位置

where swing

enter image description here

然后将该路径添加到您的环境变量中

答案 7 :(得分:0)

对于遇到类似问题的 mac 用户,当前的 pip 安装框架似乎存在问题。我跟着 this thread 并使用了链接的解决方案。似乎短期内不会有 pip 修复。

请注意,在运行上述步骤之前,您必须brew install swig - homebrew install link