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

numpy.ndarray size changed? #18

Closed
tlupien-personal opened this issue Jan 20, 2022 · 15 comments
Closed

numpy.ndarray size changed? #18

tlupien-personal opened this issue Jan 20, 2022 · 15 comments

Comments

@tlupien-personal
Copy link

error

I am getting the above error when I attempt to use this. This is what it said when I installed the latest version as was the recommended solution to a similar issue:

install

I use Ubuntu 20.04.03, Python 3.8.10, and am in working in Jupyter Lab 3.2.4.

This is a similar issue I found for another package (which I don't currently use) while researching this problem, if that is helpful: MaartenGr/BERTopic#392

It seems notable to me that now it's asking for 96 and getting 88, when before (in #12) it was asking for 88 and getting 80, but I am unfamiliar with this topic area.

Apologies if this is just me doing something wrong.

@Warren-S5
Copy link

Warren-S5 commented Feb 8, 2022

I am experiencing the same issue as above, with the error message returned being:
numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

I am running on Databricks with Python 3.8.10

@danvip10
Copy link

danvip10 commented Mar 10, 2022

Hi, I'm also getting this same error. Has anyone found a solution?

Running Python 3.8.10.

@joshlk
Copy link
Owner

joshlk commented Mar 11, 2022

Hi all, thanks for using k-means-constrained 🚀!

Sorry for the long wait. I have updated the package on PyPI - can you please try the new version pip install --upgrade k-means-constrained should do the trick (make sure it installs the v0.7.0 version). What I did was bump numpy up as I think its due to binary incompatibility between versions.

If the problem still persists can you please make sure the numpy version installed is 1.21.5 and let me know if that solves the issue.

@danvip10
Copy link

danvip10 commented Mar 11, 2022

Hi @joshlk, unfortunately I just upgraded to to k-means-constrained v0.7.0 and I still get exactly the same error... I do have numpy 1.21.5 .
As posted by @Warren-S5 the errror is ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

@joshlk
Copy link
Owner

joshlk commented Mar 11, 2022

Can you please downgrade numpy to 1.21.5 to see if it resolves the issue. I would recommend doing this in a virtual environment

@joshlk
Copy link
Owner

joshlk commented Mar 11, 2022

By the way numpy 1.25.5 currently does not exist 🤔 (see PyPI). The current latest version is 1.22.3. Can you paste me the result of python -c "import numpy; print(numpy.__version__)"

@danvip10
Copy link

danvip10 commented Mar 11, 2022

sorry that was a typo, I meant numpy 1.21.5

@joshlk
Copy link
Owner

joshlk commented Mar 11, 2022

Ok can you please provide me with the following versions:

  • Python:
  • Operating system: [Windows/MacOS/Linux]
  • numpy:
  • cython (if installed):

@danvip10
Copy link

danvip10 commented Mar 11, 2022

Python 3.8.10 
Operating system: Ubuntu 20.04.3 LTS (Focal Fossa)
numba                             0.55.0              
numpy                             1.21.5 
Cython                            0.29.28             

(edit for formatting)

@joshlk
Copy link
Owner

joshlk commented Mar 11, 2022

I've just tested on Ubuntu 20.04.3 with the above versions and it works fine for me. Did you change the numpy version after installing k-means-constrained? Could you try uninstalling numpy and k-means-constrained, and then install numpy==1.21.5 and then k-means-constrained

@danvip10
Copy link

danvip10 commented Mar 11, 2022

I just uninstalled and re-installed numpy==1.21.5 and k-means-constrained (0.7.0) but it didn't change anything.
When running from k_means_constrained_ import KMeansConstrained on a python instance I still get the same error specified above

@danvip10
Copy link

If it helps the error is also raised by doing just import k_means_constrained. See the full error message below

Python 3.8.10 (default, Nov 26 2021, 20:14:08) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import k_means_constrained
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/daniel/.local/lib/python3.8/site-packages/k_means_constrained/__init__.py", line 4, in <module>
    from .k_means_constrained_ import KMeansConstrained
  File "/home/daniel/.local/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/daniel/.local/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 96 from C header, got 88 from PyObject

@joshlk
Copy link
Owner

joshlk commented Mar 11, 2022

@danvip10 I've updated the k-means-constrained version. Can you please create a new virtual environment. Something like:

python3 -m venv ~/venv_test
source ~/venv_test/bin/activate

And then install the new version

@danvip10
Copy link

danvip10 commented Mar 11, 2022

It worked! Thanks.

As a note, it's worth mentioning that the pip install k-means-constrained installed numpy-1.22.3, which for the moment is incompatible with my numba 0.55.1 installation (which has the requirement numpy < 1.22).

As long as numpy>=1.22.0, then k-means-constrained works (both in the venv and outside), but other packages might not have updated their numpy dependencies.

Thanks for fixing it @joshlk

@joshlk
Copy link
Owner

joshlk commented Mar 11, 2022

Great. Closing this ticket. Others - please reopen if problem persists

@joshlk joshlk closed this as completed Mar 11, 2022
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

4 participants