Installing scikit-learn via pip on linux under Python 3.9 fails if numpy is not already installed. This makes it impossible (or at least much harder) to use in requirements.txt files when creating virtual environments or docker containers.
Start with a clean virtual envoronment
python -m venv .env
. .env/bin/activate
pip install scikit-image
Results in the following error:
ERROR: Command errored out with exit status 1:
command: FOLDER/.env/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-rvixazx6/scikit-image/setup.py'"'"'; __file__='"'"'/tmp/pip-install-rvixazx6/scikit-image/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-5_ug79dv
cwd: /tmp/pip-install-rvixazx6/scikit-image/
Complete output (7 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-rvixazx6/scikit-image/setup.py", line 243, in <module>
'build_ext': openmp_build_ext(),
File "/tmp/pip-install-rvixazx6/scikit-image/setup.py", line 71, in openmp_build_ext
from numpy.distutils.command.build_ext import build_ext
ModuleNotFoundError: No module named 'numpy'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
I have also tried pinning the version to 0.17.1 and 0.16.2, which doesn't work either. Running pip install numpy scikit-learn also fails, to make it succeed, they must be run separately: pip install numpy && pip install scikit-image.
# Paste the output of the following python commands
import sys; print(sys.version)
import platform; print(platform.platform())
3.9.0 (default, Nov 3 2020, 13:19:45)
[GCC 7.5.0]
Linux-4.15.0-122-generic-x86_64-with-glibc2.27
Thanks for reporting this. I believe this problem (using numpy in our setup.py before numpy is installed) is a bug which has been fixed since 0.17.2 (in https://github.com/scikit-image/scikit-image/pull/4920/, see in particular https://github.com/scikit-image/scikit-image/blob/master/setup.py#L167).
Also we don't have a wheel for python 3.9, hence the problem appears.
@scikit-image/core should we backport #4920 (or part of it) to 0.17.3?
IMO: I don't think a 0.17.3 will happen. I think release a 0.18 package will be able to solve this particular challenge.
We had discussed with @jni whether to release 0.17.3 just before 0.18 but I'm not 100% sure whether this will happen. 0.18 would also work of course.
Most helpful comment
Thanks for reporting this. I believe this problem (using numpy in our setup.py before numpy is installed) is a bug which has been fixed since 0.17.2 (in https://github.com/scikit-image/scikit-image/pull/4920/, see in particular https://github.com/scikit-image/scikit-image/blob/master/setup.py#L167).
Also we don't have a wheel for python 3.9, hence the problem appears.
@scikit-image/core should we backport #4920 (or part of it) to 0.17.3?