pip install getch : clang error - python

I am trying to install getch via pip and I have a clang error :
python -m pip install getch
Collecting getch
Using cached getch-1.0.tar.gz
Installing collected packages: getch
Running setup.py install for getch ... error
Complete output from command /usr/local/opt/python/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/qm/gj1n93fd7rg8rgz1ldq19gm80000gn/T/pip-build-RYKX8n/getch/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/qm/gj1n93fd7rg8rgz1ldq19gm80000gn/T/pip-uEGRgA-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 'getch' extension
creating build
creating build/temp.macosx-10.10-x86_64-2.7
clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c getchmodule.c -o build/temp.macosx-10.10-x86_64-2.7/getchmodule.o
getchmodule.c:36:6: warning: unused variable 'ok' [-Wunused-variable]
int ok = PyArg_ParseTuple(args, "");
^
getchmodule.c:43:6: warning: unused variable 'ok' [-Wunused-variable]
int ok = PyArg_ParseTuple(args, "");
^
getchmodule.c:55:4: error: use of undeclared identifier 'PyModuleDef_HEAD_INIT'
PyModuleDef_HEAD_INIT,
^
getchmodule.c:54:27: error: variable has incomplete type 'struct PyModuleDef'
static struct PyModuleDef getchmodule = {
^
getchmodule.c:54:15: note: forward declaration of 'struct PyModuleDef'
static struct PyModuleDef getchmodule = {
^
getchmodule.c:64:9: warning: implicit declaration of function 'PyModule_Create' is invalid in C99 [-Wimplicit-function-declaration]
return PyModule_Create(&getchmodule);
^
3 warnings and 2 errors generated.
error: command 'clang' failed with exit status 1
----------------------------------------
Command "/usr/local/opt/python/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/qm/gj1n93fd7rg8rgz1ldq19gm80000gn/T/pip-build-RYKX8n/getch/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/qm/gj1n93fd7rg8rgz1ldq19gm80000gn/T/pip-uEGRgA-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/qm/gj1n93fd7rg8rgz1ldq19gm80000gn/T/pip-build-RYKX8n/getch/
I am using Mac so cannot use msvcrt.
Thank you for your help.

The installation is failing because it's looking for python3 headers. Looking at https://pypi.python.org/pypi/getch there are two source distributions listed, getch-1.0-python2.tar.gz and getch-1.0.tar.gz.
For python 2 you need the former of those, but it looks like the latter one is being chosen (same thing happens for me). I'm not sure if/how pip is supposed to be able to know how to choose the correct one, but you can choose manually:
copying the link,
pip install https://pypi.python.org/packages/source/g/getch/getch-1.0-python2.tar.gz#md5=586ea0f1f16aa094ff6a30736ba03c50
works for me

Related

Install big float on mac OS X

I am trying to install big float on OS X but i am encountering multiple issues.
I have installed amp without any problem, but when I have tried to install mpfr I got this error:
Warning: mpfr-3.1.5 already installed, it's just not linked.
What does this mean? (I am using Homebrew).
Then, obviously, if I try to install bigfloat it doesn't work and i get this error:
Collecting bigfloat
Downloading bigfloat-0.3.0.tar.gz (216kB)
100% |████████████████████████████████| 225kB 1.6MB/s
Installing collected packages: bigfloat
Running setup.py install for bigfloat ... error
Complete output from command /Users/name/anaconda2/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-VCyOBn/bigfloat/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" build_ext -I/usr/local/include -L/usr/local/lib install --record /tmp/pip-K9AHsP-record/install-record.txt --single-version-externally-managed --compile:
running build_ext
building 'mpfr' extension
creating build
creating build/temp.macosx-10.7-x86_64-2.7
gcc -fno-strict-aliasing -I/Users/name/anaconda2/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/Users/name/anaconda2/include/python2.7 -c mpfr.c -o build/temp.macosx-10.7-x86_64-2.7/mpfr.o
In file included from /usr/local/lib/gcc/x86_64-apple-darwin15.6.0/6.2.0/include-fixed/syslimits.h:7:0,
from /usr/local/lib/gcc/x86_64-apple-darwin15.6.0/6.2.0/include-fixed/limits.h:34,
from /Users/name/anaconda2/include/python2.7/Python.h:19,
from mpfr.c:16:
/usr/local/lib/gcc/x86_64-apple-darwin15.6.0/6.2.0/include-fixed/limits.h:168:61: fatal error: limits.h: No such file or directory
#include_next <limits.h> /* recurse down to the real one */
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/Users//anaconda2/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-VCyOBn/bigfloat/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" build_ext -I/usr/local/include -L/usr/local/lib install --record /tmp/pip-K9AHsP-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-VCyOBn/bigfloat/
You must install python-devel
In OS X try to uninstall and install again:
brew uninstall python
brew install python
Also according to this issue, Osx GCC (which is just a symlink to clang) doesn't ship with OpenMP support out of the box. You can install GCC with OpenMP.
brew install gcc --without-multilib

pip install tesserocr fails with error " Failed building wheel for tesserocr"

I already have the latest builds for leptonica and tesseract
tesseract 4.00.00alpha-365-gcf0b378
leptonica-1.74.1
libjpeg 8d (libjpeg-turbo 1.3.0) : libpng 1.2.50 : libtiff 4.0.3 : zlib 1.2.8
i have also installed all dependencies like python-dev
This the error i'm getting when i do pip install tesserocr in my
virtualenv
Collecting tesserocr
Using cached tesserocr-2.1.3.tar.gz
Building wheels for collected packages: tesserocr
Running setup.py bdist_wheel for tesserocr ... error
Complete output from command /home/ajay/virtualenvs/v2/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-L3JmI9/tesserocr/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 /tmp/tmpUIPX1spip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_ext
Supporting tesseract v4.00.00dev
Configs from pkg-config: {'libraries': ['lept', 'tesseract'], 'cython_compile_time_env': {'TESSERACT_VERSION': 262144}, 'library_dirs': ['/usr/local/lib'], 'include_dirs': ['/usr/local/include']}
cythoning tesserocr.pyx to tesserocr.cpp
building 'tesserocr' extension
creating build
creating build/temp.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -I/usr/local/include -fPIC -I/usr/local/include -I/usr/include/python2.7 -c tesserocr.cpp -o build/temp.linux-x86_64-2.7/tesserocr.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
In file included from /usr/local/include/tesseract/genericvector.h:29:0,
from tesserocr.cpp:449:
/usr/local/include/tesseract/helpers.h: In member function ‘void tesseract::TRand::set_seed(const string&)’:
/usr/local/include/tesseract/helpers.h:50:5: error: ‘hash’ is not a member of ‘std’
std::hash<std::string> hasher;
^
/usr/local/include/tesseract/helpers.h:50:26: error: expected primary-expression before ‘>’ token
std::hash<std::string> hasher;
^
/usr/local/include/tesseract/helpers.h:50:28: error: ‘hasher’ was not declared in this scope
std::hash<std::string> hasher;
^
tesserocr.cpp: In function ‘tesseract::TessResultRenderer* __pyx_f_9tesserocr_13PyTessBaseAPI__get_renderer(__pyx_obj_9tesserocr_PyTessBaseAPI*, __pyx_t_9tesseract_cchar_t*)’:
tesserocr.cpp:16699:106: error: no matching function for call to ‘tesseract::TessPDFRenderer::TessPDFRenderer(__pyx_t_9tesseract_cchar_t*&, const char*)’
__pyx_t_7 = new tesseract::TessPDFRenderer(__pyx_v_outputbase, __pyx_v_self->_baseapi.GetDatapath());
^
tesserocr.cpp:16699:106: note: candidates are:
In file included from tesserocr.cpp:459:0:
/usr/local/include/tesseract/renderer.h:190:3: note: tesseract::TessPDFRenderer::TessPDFRenderer(const char*, const char*, bool)
TessPDFRenderer(const char* outputbase, const char* datadir, bool textonly);
^
/usr/local/include/tesseract/renderer.h:190:3: note: candidate expects 3 arguments, 2 provided
/usr/local/include/tesseract/renderer.h:186:16: note: tesseract::TessPDFRenderer::TessPDFRenderer(const tesseract::TessPDFRenderer&)
class TESS_API TessPDFRenderer : public TessResultRenderer {
^
/usr/local/include/tesseract/renderer.h:186:16: note: candidate expects 1 argument, 2 provided
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for tesserocr
Running setup.py clean for tesserocr
Failed to build tesserocr
Installing collected packages: tesserocr
Running setup.py install for tesserocr ... error
Complete output from command /home/ajay/virtualenvs/v2/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-L3JmI9/tesserocr/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-6eGBXb-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ajay/virtualenvs/v2/include/site/python2.7/tesserocr:
running install
running build
running build_ext
Supporting tesseract v4.00.00dev
Configs from pkg-config: {'libraries': ['lept', 'tesseract'], 'cython_compile_time_env': {'TESSERACT_VERSION': 262144}, 'library_dirs': ['/usr/local/lib'], 'include_dirs': ['/usr/local/include']}
skipping 'tesserocr.cpp' Cython extension (up-to-date)
building 'tesserocr' extension
creating build
creating build/temp.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -I/usr/local/include -fPIC -I/usr/local/include -I/usr/include/python2.7 -c tesserocr.cpp -o build/temp.linux-x86_64-2.7/tesserocr.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
In file included from /usr/local/include/tesseract/genericvector.h:29:0,
from tesserocr.cpp:449:
/usr/local/include/tesseract/helpers.h: In member function ‘void tesseract::TRand::set_seed(const string&)’:
/usr/local/include/tesseract/helpers.h:50:5: error: ‘hash’ is not a member of ‘std’
std::hash<std::string> hasher;
^
/usr/local/include/tesseract/helpers.h:50:26: error: expected primary-expression before ‘>’ token
std::hash<std::string> hasher;
^
/usr/local/include/tesseract/helpers.h:50:28: error: ‘hasher’ was not declared in this scope
std::hash<std::string> hasher;
^
tesserocr.cpp: In function ‘tesseract::TessResultRenderer* __pyx_f_9tesserocr_13PyTessBaseAPI__get_renderer(__pyx_obj_9tesserocr_PyTessBaseAPI*, __pyx_t_9tesseract_cchar_t*)’:
tesserocr.cpp:16699:106: error: no matching function for call to ‘tesseract::TessPDFRenderer::TessPDFRenderer(__pyx_t_9tesseract_cchar_t*&, const char*)’
__pyx_t_7 = new tesseract::TessPDFRenderer(__pyx_v_outputbase, __pyx_v_self->_baseapi.GetDatapath());
^
tesserocr.cpp:16699:106: note: candidates are:
In file included from tesserocr.cpp:459:0:
/usr/local/include/tesseract/renderer.h:190:3: note: tesseract::TessPDFRenderer::TessPDFRenderer(const char*, const char*, bool)
TessPDFRenderer(const char* outputbase, const char* datadir, bool textonly);
^
/usr/local/include/tesseract/renderer.h:190:3: note: candidate expects 3 arguments, 2 provided
/usr/local/include/tesseract/renderer.h:186:16: note: tesseract::TessPDFRenderer::TessPDFRenderer(const tesseract::TessPDFRenderer&)
class TESS_API TessPDFRenderer : public TessResultRenderer {
^
/usr/local/include/tesseract/renderer.h:186:16: note: candidate expects 1 argument, 2 provided
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
I get this error at the bottom
----------------------------------------
Command "/home/ajay/virtualenvs/v2/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-L3JmI9/tesserocr/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-6eGBXb-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ajay/virtualenvs/v2/include/site/python2.7/tesserocr" failed with error code 1 in /tmp/pip-build-L3JmI9/tesserocr/
Finally fixed the issue
completely removed tesseract and leptonica from the system and built everything from source
the debian package leptonica-dev for ubuntu 14.04 was the problem
these are the current builds i've compiled
$ tesseract -v
tesseract 3.04.01
leptonica-1.74.1
libjpeg 8d (libjpeg-turbo 1.3.0) : libpng 1.2.50 : libtiff 4.0.3 : zlib 1.2.8

Install Fabric error in pyenv

I want use Fabric when I product my project in AWS Ubuntu. When I read about Fabric, it required python 2.5~2.7, so I create Python virtualenv on Mac OS X:
pyenv virtualenv 2.7.5 fabric
mkdir fabric
and I run pip install fabric
(fabric)fabric $ pip install fabric
but it has 2 errors
Collecting fabric
[...]
configure: creating ./config.status
config.status: creating src/config.h
building 'Crypto.PublicKey._fastmath' extension
creating build/temp.macosx-10.11-x86_64-2.7
creating build/temp.macosx-10.11-x86_64-2.7/src
clang -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/ -I/Users/hanminsoo/.pyenv/versions/2.7.5/include/python2.7 -c
src/_fastmath.c -o build/temp.macosx-10.11-x86_64-2.7/src/_fastmath.o
src/_fastmath.c:1545:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
else if (result < 0)
~~~~~~ ^ ~
src/_fastmath.c:1621:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
else if (result < 0)
~~~~~~ ^ ~
2 warnings generated.
clang -bundle -bundle_loader python.exe -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/Users/hanminsoo/.pyenv/versions/2.7.5/lib build/temp.macosx-10.11-x86_64-2.7/src/_fastmath.o -lgmp -o build/lib.macosx-10.11-x86_64-2.7/Crypto/PublicKey/_fastmath.so
ld: file not found: python.exe
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
------------------------------------------------------
Failed building wheel for pycrypto
Running setup.py clean for pycrypto
Failed to build pycrypto
Installing collected packages: pycrypto, paramiko, fabric
Running setup.py install for pycrypto ... error
Complete output from command /Users/hanminsoo/.pyenv/versions/2.7.5/envs/fabric/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/c5/d1_cb4j92f19h5q0_cbv7bpc0000gn/T/pip-build-vsA2vJ/pycrypto/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/c5/d1_cb4j92f19h5q0_cbv7bpc0000gn/T/pip-iE2TRI-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/hanminsoo/.pyenv/versions/2.7.5/envs/fabric/include/site/python2.7/pycrypto:
clang -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/ -I/Users/hanminsoo/.pyenv/versions/2.7.5/include/python2.7 -c src/_fastmath.c -o build/temp.macosx-10.11-x86_64-2.7/src/_fastmath.o
src/_fastmath.c:1545:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
else if (result < 0)
~~~~~~ ^ ~
src/_fastmath.c:1621:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
else if (result < 0)
~~~~~~ ^ ~
2 warnings generated.
clang -bundle -bundle_loader python.exe -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/Users/hanminsoo/.pyenv/versions/2.7.5/lib build/temp.macosx-10.11-x86_64-2.7/src/_fastmath.o -lgmp -o build/lib.macosx-10.11-x86_64-2.7/Crypto/PublicKey/_fastmath.so
ld: file not found: python.exe
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
-------------------------------------------------------
Command "/Users/hanminsoo/.pyenv/versions/2.7.5/envs/fabric/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/c5/d1_cb4j92f19h5q0_cbv7bpc0000gn/T/pip-build-vsA2vJ/pycrypto/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/c5/d1_cb4j92f19h5q0_cbv7bpc0000gn/T/pip-iE2TRI-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/hanminsoo/.pyenv/versions/2.7.5/envs/fabric/include/site/python2.7/pycrypto" failed with error code 1 in /private/var/folders/c5/d1_cb4j92f19h5q0_cbv7bpc0000gn/T/pip-build-vsA2vJ/pycrypto/
Some people tell me "you should install pycrpto" so I install pycrpto
pip install pycrpto
but it has the same error when I pip install fabric. I found this solution link, so I run:
brew install gmp
export LIBRARY_PATH=/usr/local/lib
pip install pycrypto
but it has the same error and second solution is link
$ bunzip2 gmp-5.0.5.tar.bz2
but it has another error:
bunzip2: Can't open input file gmp-5.0.5.tar.bz2: No such file or directory.
I can't understand why fabric doesn't install...
It's a bug in Python <2.7.8. See pyenv#273.
You can fix it by patching _sysconfigdata.py:
$ export p=/Users/andrei/.pyenv/versions/2.7.6
$ sed -i -e "s#python.exe#${p}/bin/python2.7#g" "$p/lib/python2.7/_sysconfigdata.py"

Error updating pycups via pip

I'm running openSUSE Leap 42.1 and I just tried to update all the software in pip, using the following command:
for i in $(pip list|awk '{print $1}'); do pip install $i --upgrade;done
This hit a few errors, I had some missing devel dependencies, which I managed to fix, and most of the packages then updated fine, but one continues to fail, and I'm not sure why. The errors at this point became a bit cryptic and my google-fu was unable to find the answer. Can anyone advise why I'm getting this error, and whether there is a way to fix/work around?
Collecting pycups
Using cached pycups-1.9.73.tar.bz2
Installing collected packages: pycups
Found existing installation: pycups 1.9.72
DEPRECATION: Uninstalling a distutils installed project (pycups) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling pycups-1.9.72:
Successfully uninstalled pycups-1.9.72
Running setup.py install for pycups
Complete output from command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-vpyfl_ln/pycups/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-zukh_f21-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 'cups' extension
creating build
creating build/temp.linux-x86_64-3.4
gcc -pthread -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DOPENSSL_LOAD_CONF -fPIC -DVERSION="1.9.73" -I/usr/include/python3.4m -c cupsmodule.c -o build/temp.linux-x86_64-3.4/cupsmodule.o
cupsmodule.c: In function ‘cups_connectDest’:
cupsmodule.c:720:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
int i;
^
cupsmodule.c:743:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
PyObject *largs = Py_BuildValue ("()");
^
cupsmodule.c: In function ‘PyInit_cups’:
cupsmodule.c:1018:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
struct module_state *st = GETSTATE(m);
^
cupsmodule.c:1026:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
PyObject *d = PyModule_GetDict (m);
^
cc1: some warnings being treated as errors
error: command 'gcc' failed with exit status 1
----------------------------------------
Rolling back uninstall of pycups
Command "/usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-vpyfl_ln/pycups/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-zukh_f21-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-vpyfl_ln/pycups
I'm using the following pip:
pip 7.1.2 from /usr/lib/python3.4/site-packages (python 3.4)
The problem is this compiler flag: -Werror=declaration-after-statement. You need to tell the compiler not to turn this warning into an error by setting the CFLAGS environment variable:
CFLAGS=-Wno-error=declaration-after-statement pip install -U pycups

Having trouble installing fastcluster library, numpy include error

I'm trying to install the fastcluster Python library, but I'm running into a compilation error.
$ pip install fastcluster
produces the following output:
Collecting fastcluster
Using cached fastcluster-1.1.17.tar.gz
Building wheels for collected packages: fastcluster
Running setup.py bdist_wheel for fastcluster
Complete output from command /home/ruser/dedupe/venv/bin/python -c "import setuptools;__file__='/tmp/pip-build-9ejthV/fastcluster/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpXVyTyspip-wheel-:
Version: 1.1.17
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying fastcluster.py -> build/lib.linux-x86_64-2.7
running build_ext
building '_fastcluster' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/fastcluster_python.cpp -o build/temp.linux-x86_64-2.7/src/fastcluster_python.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
src/fastcluster_python.cpp:38:31: fatal error: numpy/arrayobject.h: No such file or directory
#include <numpy/arrayobject.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for fastcluster
Failed to build fastcluster
Installing collected packages: fastcluster
Running setup.py install for fastcluster
Complete output from command /home/ruser/dedupe/venv/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-9ejthV/fastcluster/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-85ovHC-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ruser/dedupe/venv/include/site/python2.7/fastcluster:
Version: 1.1.17
running install
running build
running build_py
running build_ext
building '_fastcluster' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/fastcluster_python.cpp -o build/temp.linux-x86_64-2.7/src/fastcluster_python.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
src/fastcluster_python.cpp:38:31: fatal error: numpy/arrayobject.h: No such file or directory
#include <numpy/arrayobject.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/home/ruser/dedupe/venv/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-9ejthV/fastcluster/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-85ovHC-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ruser/dedupe/venv/include/site/python2.7/fastcluster" failed with error code 1 in /tmp/pip-build-9ejthV/fastcluster
What would cause this? Something about setting include directories?
The issue you're seeing with installing fastcluster is related to this previous question - the compiler is not looking in the correct directory to find the numpy headers. You can use more or less the same solution as given in the accepted answer:
Download and untar the source for fastcluster
$ pip install fastcluster --download='.'
$ tar -xzf fastcluster-1.1.17.tar.gz
$ cd fastcluster-1.1.17/
Edit the setup.py file to add the output of numpy.get_include() to the include_dirs= argument for the Extension:
import numpy
...
ext_modules=[Extension('_fastcluster',
['src/fastcluster_python.cpp'],
extra_compile_args=['/EHsc'] if os.name=='nt' else [],
include_dirs=[numpy.get_include()]
)]
Install fastcluster:
$ python setup.py install
Let the fastcluster maintainer know that his package is broken :-)

Categories