luispedro / mahotas

Computer Vision in Python
https://mahotas.rtfd.io
Other
844 stars 148 forks source link

Building wheels with pip option --user or --prefix fails #86

Closed hackermd closed 4 years ago

hackermd commented 7 years ago

When mahotas is installed with pip install mahotas --user building wheels fails with the following error on Ubuntu 16.04 with Python 2.7.12:

    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -DPY_ARRAY_UNIQUE_SYMBOL=Mahotas_PyArray_API_Symbol -I[] -I/usr/include/python2.7 -c mahotas/_histogram.cpp -o build/temp.linux-x86_64-2.7/mahotas/_histogram.o
    cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
    In file included from mahotas/numpypp/array.hpp:17:0,
                     from mahotas/_histogram.cpp:10:
    mahotas/numpypp/numpy.hpp:11:33: fatal error: numpy/ndarrayobject.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for mahotas
  Running setup.py clean for mahotas
Failed to build mahotas
Installing collected packages: numpy, mahotas
  Running setup.py install for mahotas ... done
Successfully installed mahotas-1.4.3 numpy-1.12.0

This fails:

docker run -t hackermd/ubuntu-xenial-python pip install mahotas --user

This works:

docker run -t hackermd/ubuntu-xenial-python sudo pip install mahotas
luispedro commented 7 years ago

The error is related to not finding the numpy headers, but I'm not sure how the --user flag relates to it.

hackermd commented 7 years ago

When I run the same command with sudo it works:

docker run -t hackermd/ubuntu-xenial-python sudo pip install mahotas --user
luispedro commented 7 years ago

My guess is that pip does not use the global environment when using --user and you do not have numpy installed on your user directory.

Does it work if you use pip build and pip install --user in succession?

hackermd commented 7 years ago

pip wheel mahotas alone fails with the same error.

When I install numpy first separately, it works:

pip install numpy --user
pip install mahotas --user
hackermd commented 7 years ago

This also works:

sudo pip install numpy
pip install mahotas --user
burhr2 commented 4 years ago

The following link should help https://mahotas.readthedocs.io/en/latest/install.html

luispedro commented 4 years ago

I cherry-picked the commit above from @ATolkachev and this will be part of the next (upcoming) release