Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] import error with python 3.8 and numpy < 1.20 #12

Closed
awaizman1 opened this issue May 2, 2021 · 2 comments
Closed

[BUG] import error with python 3.8 and numpy < 1.20 #12

awaizman1 opened this issue May 2, 2021 · 2 comments

Comments

@awaizman1
Copy link

Describe the bug
when installing k-means-constrained in python3.8 environment with numpy < 1.20 (i.e. 1.19.5) on linux, import fails due to numpy binary incompatibility.

Details:
I think the root cause is that during package installation (PEP-517) the numpy that is used to compile the package is numpy>1.13 (as described in pyproject.toml). on python 3.8 this will collect 1.20 (in python 3.6 it will collect 1.19.5).
so the package is built with numpy1.20 but if my environment has a different numpy (1.19.5) there is some binary incompatibility issue.
maybe its better to remove numpy from pyproject.toml and let it use the installed numpy instead?

Minimum working example

Python 3.8.9 (default, Apr  3 2021, 01:00:00) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from k_means_constrained import KMeansConstrained
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/e101364/views/1v_main/Qstreams/provision-algobb/assaf/lib/python3.8/site-packages/k_means_constrained/__init__.py", line 4, in <module>
    from .k_means_constrained_ import KMeansConstrained
  File "/home/e101364/views/1v_main/Qstreams/provision-algobb/assaf/lib/python3.8/site-packages/k_means_constrained/k_means_constrained_.py", line 18, in <module>
    from .sklearn_import.metrics.pairwise import euclidean_distances
  File "/home/e101364/views/1v_main/Qstreams/provision-algobb/assaf/lib/python3.8/site-packages/k_means_constrained/sklearn_import/metrics/pairwise.py", line 10, in <module>
    from k_means_constrained.sklearn_import.metrics.pairwise_fast import _sparse_manhattan
  File "k_means_constrained/sklearn_import/metrics/pairwise_fast.pyx", line 1, in init k_means_constrained.sklearn_import.metrics.pairwise_fast
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

Versions:

  • Python: 3.8.9
  • Operating system: linux (ubuntu18.04)
  • k-means-constrained: 0.5.2
  • numpy: 1.19.5
  • scipy: 1.6.3
  • ortools: 9.0.9048
  • joblib: 1.0.1
  • cython (if installed):

Thanks

@bugra-yilmaz
Copy link

I had the same issue on Python 3.8.5, requirements.txt needs to be updated.

@joshlk
Copy link
Owner

joshlk commented May 18, 2021

Hi both,

Thanks for the bug report. Sorry it's taken me so long to get to it. I have updated the dependencies and corresponding tests. The latest version v0.6.0 should work: https://pypi.org/project/k-means-constrained/0.6.0/

Please let me know if you have any issues 😃

Josh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants