Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

install dtaidistance -> Exception: The compiled dtaidistance C library is not available

Tags:

python

numpy

dtw

I try to run dtaidistance but when running the following code according example :

from dtaidistance import dtw
import numpy as np
timeseries = np.array([
     [0., 0, 1, 2, 1, 0, 1, 0, 0],
     [0., 1, 2, 0, 0, 0, 0, 0, 0],
     [1., 2, 0, 0, 0, 0, 0, 1, 1],
     [0., 0, 1, 2, 1, 0, 1, 0, 0],
     [0., 1, 2, 0, 0, 0, 0, 0, 0],
     [1., 2, 0, 0, 0, 0, 0, 1, 1]])
ds = dtw.distance_matrix_fast(timeseries, block=((1, 4), (3, 5)))

I get the following error:

The compiled dtaidistance C library is not available.
See the documentation for alternative installation options.

I tried different IDEs (Jupyter Notebook, PyCharm, Visual Studio Code), different Laptops, older version of dtaidistance,..

Is it even possible to install the library on windows? -.-

I tried troubleshooting according: https://dtaidistance.readthedocs.io/en/latest/usage/installation.html

I tried everything according:

  • https://github.com/wannesm/dtaidistance/issues/36
  • https://github.com/wannesm/dtaidistance/issues/20

However, none of it was successful. I am in need of this library..

When running dtw.try_import_c() I get the following output:

Cannot import OMP-based library (dtw_cc_omp)
Cannot import Numpy-based library (dtw_cc_numpy)

Not all libraries are available in your installation. Share the following information when submitting a bug report:
- Cannot import OMP-based library (dtw_cc_omp)
- cannot import name 'dtw_cc_omp' from 'dtaidistance' (C:\Users\admin\anaconda3\lib\site-packages\dtaidistance\__init__.py)
- Cannot import Numpy-based library (dtw_cc_numpy)
- cannot import name 'dtw_cc_numpy' from 'dtaidistance' (C:\Users\admin\anaconda3\lib\site-packages\dtaidistance\__init__.py)
- System information:
  namespace(cache_tag='cpython-38', hexversion=50857456, name='cpython', version=sys.version_info(major=3, minor=8, micro=5, releaselevel='final', serial=0))
Additionally, you can rerun the compilation from source or pip install in verbose mode:
pip install -vvv --upgrade --force-reinstall --no-deps --no-binary :all: dtaidistance

Any ideas? Thanks a lot!

like image 952
Adler Müller Avatar asked Nov 06 '22 00:11

Adler Müller


1 Answers

I faced similar problems and this is how I solved them.

  1. Make sure that no dtaidistance related folders are in /site_packages from previous installation attemps.
  2. Follow https://dtaidistance.readthedocs.io/en/latest/usage/installation.html and compile the package from source. If OpenMP is not available, install gcc and use the --forcegnugcc argument.
  3. After building the package copy the folder /dtaidistance manually into the /site_packages folder. This step is important: Strangly, using python setup.py install did not work for me.

The steps were tested with version 2.3.2.

like image 159
Phun Avatar answered Nov 14 '22 22:11

Phun