Installing pocketsphinx python module: command 'swig.exe' failed
Solution 1:
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
-
Copy swig.exe to the python installation folder (for ex C:/python27)
-
Open the
swigwin-3.0.12/Lib
folder and copy all*.swg
files to theC:/python27/Lib
or equivalent python path -
Open
swigwin-3.0.12/Lib/python
and copy all the files toC:/python27/Lib
-
Open the
swigwin-3.0.12/Lib
folder and copy over thetypemaps
folder toC:/python27/Lib
(Also make sure you have Microsoft Visual C++ Compiler for Python installed)
These steps worked for me.
Solution 2:
Instead of copying Swig files to the Python folder, you can simply add Swig`s location to the environment variables:
- Press
Ctrl+S
- Type
env
and pressEnter
- Double click on
Path
- Add the path-to-Swig to the last blank line
- Click
OK
and restart your PC
Solution 3:
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.
Solution 4:
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