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

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

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.


To fix the problem, I downloaded swig for windows at the time of writing this answer it was 3.0.12

For the latest swig windows version follow this link

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

  2. Open the 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

  4. Open the swigwin-3.0.12/Lib folder and copy over the typemaps folder to C:/python27/Lib

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

These steps worked for me.