joshlk / k-means-constrained

K-Means clustering - constrained with minimum and maximum cluster size. Documentation: https://joshlk.github.io/k-means-constrained
https://github.com/joshlk/k-means-constrained
BSD 3-Clause "New" or "Revised" License
192 stars 43 forks source link

Issue in importing k-means-constrained in Google Colab notebook #41

Closed bhattashreya closed 1 year ago

bhattashreya commented 1 year ago

Hi Josh,

I am having an issue import the k-means-constrained package in my Colab notebook. This was working a week ago but I have been receiving the following error this week, and was wondering if there is a package incompatibility due to the numpy version I am using:


RuntimeError                              Traceback (most recent call last)
__init__.pxd in numpy.import_array()

RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf . Check the section C-API incompatibility at the Troubleshooting ImportError section at https://numpy.org/devdocs/user/troubleshooting-importerror.html#c-api-incompatibility for indications on how to solve this problem .

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
[<ipython-input-11-89081c05e795>](https://localhost:8080/#) in <cell line: 1>()
----> 1 from k_means_constrained import KMeansConstrained
      2 get_ipython().system('pip install numpy --upgrade')
      3 import numpy as np

2 frames
[/usr/local/lib/python3.10/dist-packages/k_means_constrained/sklearn_import/metrics/pairwise.py](https://localhost:8080/#) in <module>
      8 from joblib import cpu_count, delayed, Parallel
      9 
---> 10 from k_means_constrained.sklearn_import.metrics.pairwise_fast import _sparse_manhattan
     11 
     12 from k_means_constrained.sklearn_import.preprocessing.data import normalize

k_means_constrained/sklearn_import/metrics/pairwise_fast.pyx in init k_means_constrained.sklearn_import.metrics.pairwise_fast()

__init__.pxd in numpy.import_array()

ImportError: numpy.core.multiarray failed to import

Could you please let me know how to resolve this? I have tried installing and uninstalling numpy, and trying to install specific versions of numpy but am still receiving this error. Thank you!

joshlk commented 1 year ago

Hi, uploaded a new version to PyPI (v0.7.3) that uses a different method to compile for the numpy ABI. Can you try and see if it works:

pip install --upgrade k-means-constrained
joshlk commented 1 year ago

I assume this is fixed and so closing the issue. Please reopen if this issue persists or create a new issue.