luispedro / mahotas

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

Installation of mahotas fails in a clean conda environment #115

Closed Fperdreau closed 4 years ago

Fperdreau commented 4 years ago

Hello,

I have encountered some issues when trying to install mahotas in a clean conda environment. In essence, it fails building the wheels:

     11 | #include <numpy/ndarrayobject.h>
        |          ^~~~~~~~~~~~~~~~~~~~~~~
  compilation terminated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for mahotas

Here are the steps I followed:

# Clear Conda & PIP caches for replicability
conda clean --all -y
rm -rf ~/.cache/pip

# Create new conda environment
conda create -n test_mahotas python=3.7 pip -y

# Activate environment
conda activate test_mahotas

# Install Mahotas
pip install mahotas==1.4.9

It seems mahotas tries to install the lastest version of numpy (1.18.5) and thus fails to compile against this version. This is because no specific version of numpy is supplied in the requirements.txt file of mahotas.

The workaround I found was to install numpy 1.18.4 before installing mahotas. Then it works. Here is the full working procedure:

# Clear Conda & PIP caches for replicability
conda clean --all -y
rm -rf ~/.cache/pip

# Create new conda environment
conda create -n test_mahotas python=3.7 pip -y

# Activate environment
conda activate test_mahotas

# Install Mahotas
pip install numpy==1.18.4
pip install mahotas==1.4.9

I would suggest to specify the supported version of numpy in the requirements.txt file to avoid this situation in the future. I am willing to create a PR if needed.

luispedro commented 4 years ago

Worked on my side, but more generally I think the issue may be a subtle thing where if numpy is installed by the same pip call that was installing mahotas, then the paths are wrong

We will have wheels thanks to #114 (I'm in the process of doing a new release just now so it works), so building will also be unnecessary

Even better, though, if you are using conda is to use the conda package: https://anaconda.org/conda-forge/mahotas