安装pocketsphinx python模块:命令'swig.exe'失败

Kru*_*Raj 7 python swig pocketsphinx

我得到这样的东西.任何人都可以告诉我如何解决这个问题.

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\
Run Code Online (Sandbox Code Playgroud)

Jai*_*eer 18

conda install swig
pip install pocketsphinx
Run Code Online (Sandbox Code Playgroud)

我不想做其他人建议的所有设置,所以我尝试了这个并且它起作用了。不过,这可能仅在您使用 Anaconada 时才有效。

  • 在我看来,这应该是公认的答案。少即是多。 (2认同)

Moh*_*awy 11

为了解决这个问题,我下载了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)

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

这些步骤对我有用.

  • 我还需要将'typemaps'文件夹复制到C:/ python27/Lib文件夹. (5认同)
  • 我复制了“swig for windows”的 .zip 链接,安装到一个目录中,将该目录添加到我的环境变量 PATH 中 - 重新打开一个新终端并运行“pip install PocketSphinx”,这次成功了。 (2认同)

Gui*_*not 9

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

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

要确定您必须下载哪个版本,可以运行以下命令,这些命令将告诉您所需的版本以及运行32位还是64位python解释器。

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

下载正确的版本后,您可以输入以下命令

"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
Run Code Online (Sandbox Code Playgroud)


Ram*_*mar 5

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

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

sudo pip install pocketsphinx
Run Code Online (Sandbox Code Playgroud)

来源:pocketsphinx-python


W B*_*eto 5

无需将Swig文件复制到Python文件夹,您只需将Swig的位置添加到环境变量中即可:

  1. Ctrl+S
  2. 输入env并按Enter
  3. 双击 Path
  4. Swig路径添加到最后一个空行
  5. 单击OK并重新启动您的PC

  • 您的意思是 1. [Windows 键] + S 吗?2. 编辑环境变量?3. 在 3 ? 之前按“环境变量” 根据https://superuser.com/questions/130029/refresh-environment-variable,您可以注销并再次登录,而不是5.重新启动 (3认同)
  • 我是已接受答案的作者,我同意这个更好 (2认同)