I couldn't install textract in google colab, error message showing as below.
some people suggest to use sudo apt-get install libasound2-dev but how to do sudo... in google colab?
=== error message ==========================================================
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 ...
error
Complete output from command /usr/bin/python3 -u -c "import setuptools,
tokenize;file='/tmp/pip-install-03c_ysbm/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 /tmp/pip-record-6n9ewg9i/install-record.txt --single-version-externally-managed --compile:
running install
running build_ext
building 'sphinxbase._sphinxbase' extension
swigging deps/sphinxbase/swig/sphinxbase.i to deps/sphinxbase/swig/sphinxbase_wrap.c
swig -python -modern -threads -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -Ideps/sphinxbase/swig -outdir sphinxbase -o deps/sphinxbase/swig/sphinxbase_wrap.c
deps/sphinxbase/swig/sphinxbase.i
unable to execute 'swig': No such file or directory
error: command 'swig' failed with exit status 1
===========================================================================
Thank you,
Ling
Nope you can't use sudo because you don't get root access for colab.
The problem is that you don't just need libasound2-dev but a whole host of packages. Check debian requirements in https://textract.readthedocs.io/en/stable/installation.html
Also in order to build sphinx (a requirement for textract) you need libpulse-dev. So here is the updated command list.
!apt-get install python-dev libxml2-dev libxslt1-dev antiword unrtf poppler-utils \
pstotext tesseract-ocr \
flac ffmpeg lame libmad0 libsox-fmt-mp3 sox libjpeg-dev swig libasound2-dev libpulse-dev
!pip install git+https://github.com/deanmalmgren/textract
In google colab Bash commands run by prefixing the command with ‘!’.
Example:
!apt update
!apt-get install libasound2-dev
Related
I got the following error while trying to install pyaudio using pip3 in ubuntu 16.04:
Collecting pyaudio
Downloading PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-mxgvewdb/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-v55chjee-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.5
copying src/pyaudio.py -> build/lib.linux-x86_64-3.5
running build_ext
building '_portaudio' extension
creating build/temp.linux-x86_64-3.5
creating build/temp.linux-x86_64-3.5/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c src/_portaudiomodule.c -o build/temp.linux-x86_64-3.5/src/_portaudiomodule.o
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-mxgvewdb/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-v55chjee-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-mxgvewdb/pyaudio/
This should help
$ sudo apt-get install portaudio19-dev python-pyaudio python3-pyaudio
Tested on Ubuntu 18.04, Python 3.7.2, pyaudio 0.2.11
Added 8th of Jan 2021:
On Ubuntu 20.04 you have to use:
$ sudo apt install portaudio19-dev python3-pyaudio
For Windows, here's what I've been going through...
There're several ways to install PortAudio
vcpkg, https://vcpkg.info/port/portaudio
winget, https://winget.run/pkg/intxcc/pyaudio
Or, manually build from source and install manually
download source, http://files.portaudio.com/download.html
build with cmake, with the matching compiler(msvc/mingw) and arch(x64/x86) to your Python
put "portaudio.h" into python-include directory, e.g. c:\Python38-32\include\
put "portaudio.lib into python-lib directory, e.g. c:\Python38-32\libs
Arrh!
the "min()" macro in pyaudio's soucefile _portaudiomodule.c is troublesome, comment it out manually
pip install pyaudio --no-clean
find _portaudiomodule.c in the temp directory and manually comment-out the "min()" macro e.g. c:\Temp\pip-install-yysb8bme\pyaudio_c92585\src\_portaudiomodule.c
pip install from that directorye.g. pip install c:\Temp\pip-install-yysb8bme\pyaudio_c92585\
Or,3rd party wheels
this answer said:
pip install pipwinpipwin install pyaudio
For MacOS (Intel/Apple Silicon):
Step 1:
brew install portaudio
Step 2:
brew --prefix portaudio
The output provided from the above command, will be required in Step 3, which will look something similar to /opt/homebrew/opt/portaudio
Step 3:
Create .pydistutils.cfg in your home directory
sudo nano ~/.pydistutils.cfg
then paste the following in the file, save and exit
[build_ext]
include_dirs=<PATH FROM STEP 2>/include/
library_dirs=<PATH FROM STEP 2>/lib/
Step 4:
pip3 install pyaudio
For Centos7/RHEL:
yum install portaudio-devel alsa-lib-devel portaudio
pip install pyaudio --user
I am trying to install pymupdf package on apline image but getting below error
fitz/fitz_wrap.c:2739:10: fatal error: ft2build.h: No such file or directory
2739 | #include <ft2build.h>
| ^~~~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
RUN pip install PyMuPDF
---> Running in 34d246d6f01b
Collecting PyMuPDF
Downloading PyMuPDF-1.18.5.tar.gz (251 kB)
Using legacy 'setup.py install' for PyMuPDF, since package 'wheel' is not installed.
Installing collected packages: PyMuPDF
Running setup.py install for PyMuPDF: started
Running setup.py install for PyMuPDF: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-uxc_zm2j/pymupdf/setup.py'"'"'; __file__='"'"'/tmp/pip-install-uxc_zm2j/pymupdf/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-nipvlcn8/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.8/PyMuPDF
cwd: /tmp/pip-install-uxc_zm2j/pymupdf/
Complete output (20 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/fitz
copying fitz/__init__.py -> build/lib.linux-x86_64-3.8/fitz
copying fitz/fitz.py -> build/lib.linux-x86_64-3.8/fitz
copying fitz/utils.py -> build/lib.linux-x86_64-3.8/fitz
copying fitz/__main__.py -> build/lib.linux-x86_64-3.8/fitz
running build_ext
building 'fitz._fitz' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/fitz
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Os -fomit-frame-pointer -g -Os -fomit-frame-pointer -g -Os -fomit-frame-pointer -g -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/include/mupdf -I/usr/local/include/mupdf -Imupdf/thirdparty/freetype/include -I/usr/include/python3.8 -c fitz/fitz_wrap.c -o build/temp.linux-x86_64-3.8/fitz/fitz_wrap.o
fitz/fitz_wrap.c:2739:10: fatal error: ft2build.h: No such file or directory
2739 | #include <ft2build.h>
| ^~~~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-uxc_zm2j/pymupdf/setup.py'"'"'; __file__='"'"'/tmp/pip-install-uxc_zm2j/pymupdf/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-nipvlcn8/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.8/PyMuPDF Check the logs for full command output.
WARNING: You are using pip version 20.2.4; however, version 20.3.3 is available.
You should consider upgrading via the '/usr/bin/python3.8 -m pip install --upgrade pip' command.
The command '/bin/sh -c pip install PyMuPDF' returned a non-zero code: 1
freetype-dev in Alpine will be installed in /usr/include/freetype2. You can link headers and directories to /usr/include
apk add mupdf-dev installed mupdf with a method structure inconsistent with that of pymupdf,So you need to compile the mupdf library from source code.
FROM python:3.8-alpine
RUN apk add gcc g++ cmake make mupdf-dev freetype-dev
ARG MUPDF=1.18.0
RUN ln -s /usr/include/freetype2/ft2build.h /usr/include/ft2build.h \
&& ln -s /usr/include/freetype2/freetype/ /usr/include/freetype \
&& wget -c -q https://www.mupdf.com/downloads/archive/mupdf-${MUPDF}-source.tar.gz \
&& tar xf mupdf-${MUPDF}-source.tar.gz \
&& cd mupdf-${MUPDF}-source \
&& make HAVE_X11=no HAVE_GLUT=no shared=yes prefix=/usr/local install \
&& cd .. \
&& rm -rf *.tar.gz mupdf-${MUPDF}-source
RUN pip install PyMuPDF==1.18.9
Try this , it works
Also, Alpine's official Mupdf library has been updated to make installation easier.(Updated at 2021-04-28)
FROM python:3.8-alpine
# Add temporary virtual environment dependencies
RUN apk --no-cache add --virtual .builddeps gcc g++
# These dependency packages cannot be removed because they continue to be used in PyMupdf
RUN apk --no-cache add mupdf-dev freetype-dev jbig2dec-dev jpeg-dev openjpeg-dev
# install PyMupdf
RUN pip install pymupdf
# Remove virtual environment dependencies
RUN apk del .builddeps
For those kind of errors there are simple steps to take:
Read the error and identify the missing file, you have done it already, you seems to be missing ft2build.h
Go the the Alpine package website and browse the Contents tab
In the field File type in the name of the file you are missing; in Branch, select your Alpine version and in Repository select main
This will point you at a sepcific package, just install it via apk in your Dockerfile and you should be good to go
In your case, this is the result of such a search on Alpine version 3.12:
So you issue can be fixed adding in the existing apk command the package freetype-dev
RUN apk add --no-cache \
freetype-dev
Try to update pip first with pip install -U pip.
Here is a deep dive into the problem https://github.com/pymupdf/PyMuPDF/issues/894
there an old pip that get source from tar.gz file rather than .whl and the build has been failed because of wrong INCLUDE dir for freetype2 which is workarounded since PyMuPDF 1.18.2 but... Pypi has outdated source tar.gz.
The problem is that there is no wheel on PyPI for the envrionment established by the docker file.
In such cases, pip tries to create PyMuPDF from sources.
Because PyMuPDF is a binding for MuPDF, this in turn is bound to fail, when there is no MuPDF installation ... like here.
The solution therefore is to
either install MuPDF before installing PyMuPDF
or use one of the OS / Python combinations for which there is a wheel.
this work for me, and only work with python:3.8.10 or greater and with Pymupdf:1.18.14:
1). Only if you don't have python installed:
apk add --update py-pip
2). Install dependencies:
apk add --no-cache \
python3-dev \
mupdf-dev \
gcc \
libc-dev \
musl-dev \
jbig2dec \
openjpeg-dev \
jpeg-dev \
harfbuzz-dev
3). Create Shortcut:
ln -s /usr/lib/libjbig2dec.so.0 /usr/lib/libjbig2dec.so
4). install PymuPdf:
pip install pymupdf
only if you want do at same time:
apk add --update py-pip \
&& apk add --no-cache \
python3-dev \
mupdf-dev \
gcc \
libc-dev \
musl-dev \
jbig2dec \
openjpeg-dev \
jpeg-dev \
harfbuzz-dev \
&& ln -s /usr/lib/libjbig2dec.so.0 /usr/lib/libjbig2dec.so \
&& pip install pymupdf
I am having issues installing a pip package on Windows 10 WSL running Debian Stretch.
While running sudo pip install invoice2data, with python3-pip installed I run into following errors.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for regex
Running setup.py clean for regex
Failed to build regex
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c regex_2/_regex.c -o build/temp.linux-x86_64-2.7/regex_2/_regex.o
regex_2/_regex.c:46:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, okenize;__file__='/tmp/pip-install-D9zG6P/regex/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-0dvlsB/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-D9zG6P/regex/
WSL is unrelated to the issue, this is a fairly standard error.
Ensure the following packages are installed. Install them using apt-get install packagename. The issue this particular time was resolved by installing python-dev.
python3
python3-pip
ipython3
build-essential
python-dev
python3-dev
As a single command:
sudo apt-get install python3 python3-pip ipython3 build-essential python-dev python3-dev
Had a similar error while running pip3 install pyinquirer
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-a7ojseph/regex/setup.py'"'"'; __file__='"'"'/tmp/pip-install-a7ojseph/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-bodowot9/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7/regex Check the logs for full command output.
Installing python3-dev didn't work for me, as I already had it installed. However installing build-essential did the trick and the regex module installed successfully.
I'm running Python 3.5 on Ubuntu. How I was able to install the regex Python package is:
$ sudo apt-get install libpython3.5-dev
$ pip3 install regex --no-use-wheel
Background research details:
I determined the package name that provides the missing Python.h file by using apt-file to locate it.
# install the apt-file package in case you don't have it
$ sudo apt-get install apt-file
# populate/refresh the local apt-file package data
$ sudo apt-file update
# search for /Python.h. Since it's a C header file,
# I also grep for /include to limit the results.
$ sudo apt-file search /Python.h | grep /include
libpython2.7-dbg: /usr/include/python2.7_d/Python.h
libpython2.7-dev: /usr/include/python2.7/Python.h
libpython3.5-dbg: /usr/include/python3.5dm/Python.h
libpython3.5-dev: /usr/include/python3.5m/Python.h
pypy-dev: /usr/lib/pypy/include/Python.h
Then made an educated guess as to which package I needed. Ignore Python2, ignore debug (dbg), ignore pypy, thus leaving libpython3.5-dev.
I landed on this page when I had a similar error on Alpine so I will leave this solution here for the alternate me when he has a similar issue :)
apk add build-base --no-cache
https://wiki.alpinelinux.org/wiki/GCC
restart the bash. I had the same error, but restarting helped
If your interpreter is pypy, then install following packages: using sudo apt-get install 'packagename'
pypy3
pypy3-pip
ipypy3
build-essential
pypy-dev
pypy3-dev
Works perfectly for installing nltk and regex
I have searched all over the web and especially have gone through all the questions regarding this here on Stackoverflow.
I am using the following command to install it "pip install pocketsphinx"
I have windows x64,
I have not set any environmental paths regarding Swig.
Also I've downloaded Swig zip file and extracted it into my downloads folder, searched through it and there is no "swig.exe" file.
Below you can see the error/log from the command prompt.
C:\Users\User>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 ... error
Complete output from command c:\users\user\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\User\\AppData\\Local\\Temp\\pip-build-i770rcof\\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\User\AppData\Local\Temp\tmpgkhbp3u1pip-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 ... error
Complete output from command c:\users\user\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\User\\AppData\\Local\\Temp\\pip-build-i770rcof\\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\User\AppData\Local\Temp\pip-s5wxsxzb-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
Any assistance is highly appreciated,
thanks in advance!
Alright, I solved it. Here’s how:
First I went to their official website and downloaded the swigwin file specifically for windows with a “swig.exe” file.
Then I extracted it, and added it to the environment variable PATH. This solved my problem.
Afterwards I got another error, it couldn’t find visual studio C++ build tools v14.0 (along these lines), if you have this problem too just, download the C++ build tools 2015 from their official website, install, then find it in your Program Files or what ever, copy the path to the VC folder and add it to your environment variable PATH as well.
This allowed me to download/install pocketsphinx on windows.
First run your IDE or CMD as Administrator and run the following:
pip install pipwin
pipwin install pocketsphinx
If you just want to install pocketsphinx on windows, then you can install binary of pocketsphinx. The binaries suited to your system can be found here
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pocketsphinx
Chose right binary for your system and then you can install it using following command
python -m pip install pocketsphinx‑downloaded_wheel.whl
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\
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 the C:/python27/Lib or equivalent python path
Open swigwin-3.0.12/Lib/python and copy all the files to C:/python27/Lib
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.
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.
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 press Enter
Double click on Path
Add the path-to-Swig to the last blank line
Click OK and restart your PC
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
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
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.
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
what works for me is installing swing from conda and
conda install swig
if installed search where it is installed
where swig
then add that path to your environment variable
For mac users getting similar issues, there seems to be a problem with the current pip install framework. I followed this thread and used the solution linked. It doesn't seem like there will be a pip fix anytime soon.
Note you'll have to brew install swig before running the above steps - homebrew install link.
pip install pipwin
python -m pipwin install pocketsphinx
You can also use pipwin to install pocketsphinx.
For a purely pip-based fix (may or not work depending on your exact issue/system):
pip install swig
pip install pocketsphinx
pip freeze > requirements.txt
Fixed the issue simply for me. With pip freeze, you're likely to not have the issue again if cloning the project in another system (since swig will be installed just with pip install -r requirements.txt)
This is the kind of things for which it becomes REALLY worthwhile to look into using virtualenv or similar, instead of polluting (and endlessly re-configuring) your system.
I know I am late, but what worked for me was to download the pre-built wheel file and install it manually (tested on Windows. I am pretty sure it will only work on Windows).
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pocketsphinx
Just grab the right one (cp39 = python 3.9). When it finishes downloading, navigate to your downloads folder in cmd, and issue the following command:
pip install pocketsphinx-0.1.15-cp39-cp39-win_amd64.whl
NOTE: Change pocketsphinx-0.1.15-cp39-cp39-win_amd64.whl to the name of the whl file you downloaded. I grabbed this one because I use Python 3.9 64bit version.