pythonpython-3.xscikit-learn

Python 3.10.4 scikit-learn import hangs when executing via CPP


Python 3.10.4 is embedded into cpp application. I'm trying to import sklearn library which is installed at custom location using pip --target.

sklearn custom path (--target path) is appended to sys.path.

Below is a function from the script which just prints the version information.

Execution using Command Line works well as shown below.

python3.10 -c 'from try_sklearn import *; createandload()'

Output

[INFO ] [try_sklearn.py:23] 3.10.4 (main, Aug  4 2023, 01:24:50) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
[INFO ] [try_sklearn.py:24] sklearn /users/xxxx/temp/python/scikit-learn/sklearn/__init__.py Version = 1.5.1

The same script when called using CPP, hangs at

import sklearn

Other libraries like pandas, numpy etc works without any issues.


Solution

  • https://github.com/scipy/scipy/issues/21189

    Looks like Scipy and Numpy do not support Embedded python