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

时光怂恿深爱的人放手 提交于 2020-01-11 05:01:09

问题


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\

回答1:


To fix the problem, I downloaded swig for windows

  1. Copy swig.exe to the python installation folder (for ex C:/python27)

  2. Open swigwin-3.0.12/Lib folder and copy all *.swg files to the C:/python27/lib or equivalent python path

  3. Open swigwin-3.0.12/lib/python and copy all the files to (C:/python27/lib)

(Also make sure you have Microsoft Visual C++ Compiler for Python installed)

These steps worked for me.




回答2:


You try to install pocketsphinx with pip, that will download and compile this module. It requires some compiling tool like 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.

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.

"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



回答3:


Instead of copying Swig files to the Python folder, you can simply add Swig`s location to the environment variables:

  1. Press Ctrl+S
  2. Type env and press Enter
  3. Double click on Path
  4. Add the path-to-Swig to the last blank line
  5. Click OK and restart your PC



回答4:


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.




回答5:


I was also getting same error, while installing in ubuntu 16.04, I executed following commands:

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

sudo pip install pocketsphinx

source: pocketsphinx-python




回答6:


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.

This worked for me, hope it helps.




回答7:


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


来源:https://stackoverflow.com/questions/44504899/installing-pocketsphinx-python-module-command-swig-exe-failed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!