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

ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject #378

Open
DeWaRs1206 opened this issue Jan 7, 2021 · 23 comments

Comments

@DeWaRs1206
Copy link

Hello,

I'm trying to use TA-lib on my Ubuntu 18.04 instance.
I installed the package using

sudo ./configure
sudo make
sudo make install

and then install ta-lib using pip install ta-lib

When I try to import talib, I got the following error:

>>> import talib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/user/virtualenv/lib/python3.7/site-packages/talib/__init__.py", line 52, in <module>
    from ._ta_lib import (
  File "talib/_ta_lib.pyx", line 1, in init talib._ta_lib
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

The only recommendation I found on internet was to install python 3.8 which isn't a possibility for me right now (to many dependencies on my project).
Any idea what's the issue could be ?

Thanks in advance.

@gotsteez
Copy link

Am having this issue as well on my server, but not on local Ubuntu. Have u found a fix?

@mrjbq7
Copy link
Member

mrjbq7 commented Jan 29, 2021 via email

@gotsteez
Copy link

Updated python3 to python3.8 and now the error is not there anymore

@leejh3224
Copy link

Updating numpy==1.20.0 also helped in my case. (have used numpy==1.19.5)

@xmatthias
Copy link
Contributor

You might wanna reference pypa/pip#9542 regarding this, as the pip build-behaviour that's causing this is being discussed there.

@dleclair
Copy link

dleclair commented Feb 7, 2021

I ran into this as well. Looks like updating to numpy==1.20.0 does indeed resolve it but I'm wondering if it will break again the next time numpy puts out another release.

Is the issue here that ta-lib is being installed against the latest available version of numpy which may be different from the version of numpy installed in the runtime environment?

@xmatthias
Copy link
Contributor

numpy is ABI forward compatible - so if you got ta-lib installed once, it'll work, as a new version will always be newer.

During build time, pip installs the latest version (see issue above) in the build environment. If your environment then has a older version, it may break (as shown here).

Apparently, this can be fixed by changing the build-dependency to oldest-supported-numpy - as this will exploit the forward compatibility

@DeWaRs1206
Copy link
Author

DeWaRs1206 commented May 6, 2021

@mrjbq7 using python3.7 -m pip install ta-lib instead of pip install ta-lib and it worked.
(I'm using a virtualenv, so I'm not sure why this is the solution tbh)

@ManuelSchneid3r
Copy link

I ran into this as well. Looks like updating to numpy==1.20.0 does indeed resolve it but I'm wondering if it will break again the next time numpy puts out another release.

this sucks since tensorflow-macos 2.5 is tied to 1.19

@mrjbq7
Copy link
Member

mrjbq7 commented Sep 20, 2021 via email

@mripani
Copy link

mripani commented Nov 13, 2021

I’m currently trying to build a Docker container with some libraries, between them are: numpy ;ta-lib.

The problem is that some library requires numpy<=1.19 and when using that version of numpy presents this error:

ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from
PyObject

That binary incompatibility was fixed in numpy>=1.20, but I can't use that numpy version because of other dependencies that requires numpy<=1.19

There is any way to build a Docker container with ta-lib and numpy<=1.19?

@mrjbq7
Copy link
Member

mrjbq7 commented Nov 13, 2021 via email

@mripani
Copy link

mripani commented Nov 13, 2021

I already tried it. Another error appeared:

[8/8] RUN sudo make cython:                                                                                                                                                                                         
#12 0.689 make: *** No rule to make target 'cython'.  Stop.                                                                                                                                                            
------                                                                                                                                                                                                                 
executor failed running [/bin/sh -c sudo make cython]: exit code: 2    

Should work fine. You might need to regenerate the C files using Cython. You can run “make cython” to do that

On Nov 13, 2021, at 9:19 AM, Maximo Ripani @.***> wrote:  I’m currently trying to build a Docker container with some libraries, between them are: numpy ;ta-lib. The problem is that some library requires numpy<1.19 and when using that version of numpy presents this error: ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject Those binary incompatibility where fixed in numpy>=1.20, but I can't use that version of numpy because another dependencies. Therre is any way to build a Docker container with ta-lib and numpy<=1.19? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

@mrjbq7
Copy link
Member

mrjbq7 commented Nov 15, 2021

I dunno about your Docker integration, but it's there:

$ make cython
cython --directive emit_code_comments=False talib/_ta_lib.pyx

But maybe that's not the way to fix it -- the next release will no longer specify a numpy version, which might make it easier to support various combinations of versions.

@mripani
Copy link

mripani commented Jan 26, 2022

Hello! I'm steel dealing with the error

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.8/site-packages/talib/__init__.py", line 93, in <module> from ._ta_lib import ( File "talib/_ta_lib.pyx", line 1, in init talib._ta_lib ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

I'm currently using numpy==1.21.5 and TA-Lib==0.4.24.

To solve the error I should update to numpy==1.22 but other dependencies that I have work only for numpy<=1.21.*.

Is possible to work with TA-Lib and numpy<=1.21?

@mrjbq7
Copy link
Member

mrjbq7 commented Jan 26, 2022

I don't specify a version of numpy that's required.

@mrjbq7
Copy link
Member

mrjbq7 commented Jan 26, 2022

Have you tried doing a git checkout and installing from python setup.py install?

That would allow you to regenerate the C bindings for your local numpy version (make cython)

@keivanK1
Copy link

I had the same problem and could solve it by updating the numpy:

pip install --upgrade numpy

I have ta-lib==0.4.24 and numpy==1.22.3

Hello,

I'm trying to use TA-lib on my Ubuntu 18.04 instance. I installed the package using

sudo ./configure
sudo make
sudo make install

and then install ta-lib using pip install ta-lib

When I try to import talib, I got the following error:

>>> import talib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/user/virtualenv/lib/python3.7/site-packages/talib/__init__.py", line 52, in <module>
    from ._ta_lib import (
  File "talib/_ta_lib.pyx", line 1, in init talib._ta_lib
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

The only recommendation I found on internet was to install python 3.8 which isn't a possibility for me right now (to many dependencies on my project). Any idea what's the issue could be ?

Thanks in advance.

@mrjbq7
Copy link
Member

mrjbq7 commented Mar 30, 2022 via email

@drmalabbasi
Copy link

I had the same problem and could solve it by updating the numpy:

pip install --upgrade numpy

I have ta-lib==0.4.24 and numpy==1.22.3

Hello,
I'm trying to use TA-lib on my Ubuntu 18.04 instance. I installed the package using

sudo ./configure
sudo make
sudo make install

and then install ta-lib using pip install ta-lib
When I try to import talib, I got the following error:

>>> import talib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/user/virtualenv/lib/python3.7/site-packages/talib/__init__.py", line 52, in <module>
    from ._ta_lib import (
  File "talib/_ta_lib.pyx", line 1, in init talib._ta_lib
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

The only recommendation I found on internet was to install python 3.8 which isn't a possibility for me right now (to many dependencies on my project). Any idea what's the issue could be ?
Thanks in advance.

its WORKED with me :)
Thank you

@dahlo
Copy link

dahlo commented Oct 28, 2022

Same, pip install --upgrade numpy solved it for me. I had 1.20.3 and upgraded to 1.23.4

@dalklein
Copy link

dalklein commented Oct 18, 2024

old thread, but same issue? I have python3.12, numpy-2.1.2 and TA-Lib-0.4.32
It was all working fine in ubuntu22.04 (python3.10 system with python3.11 venv to run in) and I fell for the ubuntu24.04 'up'grade which uses python3.12 for system and blew away the earlier versions of python.

Traceback (most recent call last):
  File "/home/dklein/FiPy/tv_ib_ptl/ptl_trail_stop_exit_1012.py", line 3, in <module>
    import talib as ta
  File "/home/dklein/FiPy/tv_ib_ptl/.venv312/lib/python3.12/site-packages/talib/__init__.py", line 93, in <module>
    from ._ta_lib import (
  File "talib/_ta_lib.pyx", line 1, in init talib._ta_lib
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject```

@crackedminds333
Copy link

old thread, but same issue? I have python3.12, numpy-2.1.2 and TA-Lib-0.4.32 It was all working fine in ubuntu22.04 (python3.10 system with python3.11 venv to run in) and I fell for the ubuntu24.04 'up'grade which uses python3.12 for system and blew away the earlier versions of python.

Traceback (most recent call last):
  File "/home/dklein/FiPy/tv_ib_ptl/ptl_trail_stop_exit_1012.py", line 3, in <module>
    import talib as ta
  File "/home/dklein/FiPy/tv_ib_ptl/.venv312/lib/python3.12/site-packages/talib/__init__.py", line 93, in <module>
    from ._ta_lib import (
  File "talib/_ta_lib.pyx", line 1, in init talib._ta_lib
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject```

The fix here seemed to have worked for me
#655 (comment)

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