david-cortes / isotree

(Python, R, C/C++) Isolation Forest and variations such as SCiForest and EIF, with some additions (outlier detection + similarity + NA imputation)
https://isotree.readthedocs.io
BSD 2-Clause "Simplified" License
186 stars 38 forks source link

Problems installing isotree in Sagemaker Studio #53

Closed dawid-laszuk-sp closed 1 year ago

dawid-laszuk-sp commented 1 year ago

Silly question but any chance someone could elaborate what are the requirements to install isotree?

I'm facing some issues while compiling the code. I've tried a few things but nothing worked so thought that I might just ask at the source; being laughed at is a good trade. Logs depend on the kernel so below are logs from a fresh install on a Base Python 2.0 (Python 3.8.12).

Any suggestions are more than welcome.

> !python --version

Python 3.8.12

> !apt-get update && apt-get install -y build-essential

Hit:1 http://security.debian.org/debian-security bullseye-security InRelease
Hit:2 http://deb.debian.org/debian bullseye InRelease
Hit:3 http://deb.debian.org/debian bullseye-updates InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
build-essential is already the newest version (12.9).
0 upgraded, 0 newly installed, 0 to remove and 150 not upgraded.

> !python -m pip install --upgrade cython

Requirement already satisfied: cython in /usr/local/lib/python3.8/site-packages (3.0.0)

> !python -m pip install -U isotree==0.5.17

Collecting isotree==0.5.17
  Using cached isotree-0.5.17.tar.gz (288 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: isotree
  Building wheel for isotree (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for isotree (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [64 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-38
      creating build/lib.linux-x86_64-cpython-38/isotree
      copying isotree/__init__.py -> build/lib.linux-x86_64-cpython-38/isotree
      running build_ext
      --- Checking compiler support for option '-march=native'
      --- Checking compiler support for option '-fopenmp'
      --- Checking compiler support for '__restrict' qualifier
      --- Checking compiler support for option '-O3'
      --- Checking compiler support for option '-fno-math-errno'
      --- Checking compiler support for option '-fno-trapping-math'
      --- Checking compiler support for option '-std=c++17'
      --- Checking compiler support for option '-flto'
      Compiling isotree/cpp_interface.pyx because it changed.
      [1/1] Cythonizing isotree/cpp_interface.pyx
      building 'isotree._cpp_interface' extension
      creating build/temp.linux-x86_64-cpython-38
      creating build/temp.linux-x86_64-cpython-38/isotree
      creating build/temp.linux-x86_64-cpython-38/src
      gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -D_USE_XOSHIRO -D_FOR_PYTHON -DSUPPORTS_RESTRICT=1 -D_USE_ROBIN_MAP -I/tmp/pip-build-env-q0e7ht52/overlay/lib/python3.8/site-packages/numpy/core/include -I. -I./src -I/usr/local/include/python3.8 -c isotree/cpp_interface.cpp -o build/temp.linux-x86_64-cpython-38/isotree/cpp_interface.o -march=native -fopenmp -O3 -fno-math-errno -fno-trapping-math -std=c++17 -flto
      In file included from /tmp/pip-build-env-q0e7ht52/overlay/lib/python3.8/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,
                       from /tmp/pip-build-env-q0e7ht52/overlay/lib/python3.8/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                       from /tmp/pip-build-env-q0e7ht52/overlay/lib/python3.8/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                       from isotree/cpp_interface.cpp:1162:
      /tmp/pip-build-env-q0e7ht52/overlay/lib/python3.8/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
         17 | #warning "Using deprecated NumPy API, disable it with " \
            |  ^~~~~~~
      isotree/cpp_interface.cpp:3373:21: error: conflicting declaration of ‘void cy_warning(const char*)’ with ‘C++’ linkage
       3373 | __PYX_EXTERN_C void cy_warning(char const *); /*proto*/
            |                     ^~~~~~~~~~
      In file included from ./src/headers_joined.hpp:63,
                       from isotree/cpp_interface.cpp:1174:
      ./src/isotree.hpp:115:21: note: previous declaration with ‘C’ linkage
        115 |     extern "C" void cy_warning(const char *msg);
            |                     ^~~~~~~~~~
      /tmp/pip-build-env-q0e7ht52/overlay/lib/python3.8/site-packages/setuptools/_distutils/extension.py:134: UserWarning: Unknown Extension options: 'install_requires'
        warnings.warn(msg)
      warning: isotree/cpp_interface.pyx:223:89: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:229:76: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:235:64: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:240:88: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:254:45: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:266:45: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:273:59: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:282:33: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:291:33: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:299:47: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:307:47: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:335:94: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:346:62: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:359:119: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:366:63: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:391:77: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:400:72: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:402:132: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:404:135: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:426:139: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:432:20: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:440:20: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: isotree/cpp_interface.pyx:442:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for isotree
Failed to build isotree
ERROR: Could not build wheels for isotree, which is required to install pyproject.toml-based projects
david-cortes commented 1 year ago

This is fixed in the latest version:

pip install isotree==0.5.21

If you need an older version for some reason, you'll need to disable build isolation.

dawid-laszuk-sp commented 1 year ago

@david-cortes thanks for quick answer. The problem with 0.5.21 is that it depends on numpy>=1.25 which requires Python 3.9. Not sure if I can upgrade the version at the moment.

Any chance you could share how to "disable build isolation"?

david-cortes commented 1 year ago

@david-cortes thanks for quick answer. The problem with 0.5.21 is that it depends on numpy>=1.25 which requires Python 3.9. Not sure if I can upgrade the version at the moment.

Any chance you could share how to "disable build isolation"?

You could try some google searches about "pip disable build isolation". Something like this might do:

pip install --no-use-pep517 isotree
dawid-laszuk-sp commented 1 year ago

Thank you once again and apologies for a silly question. Unfortunately, once things fail where they look obvious, I doubt my skills of comprehending docs.

Unfortunately, after trying different versions on isotree and installing with different flags on pip, including --no-use-pep517 and --no-build-isolation, and upgrading/downgrading setuptools, numpy, pip... I gave up on this task.

Upgrading Python to 3.10 resolved the issue.