ta-lib-python icon indicating copy to clipboard operation
ta-lib-python copied to clipboard

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

Open DeWaRs1206 opened this issue 4 years ago • 23 comments

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.

DeWaRs1206 avatar Jan 07 '21 14:01 DeWaRs1206

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

gotsteez avatar Jan 29 '21 03:01 gotsteez

I suspect it’s an issue with pip being different than the Python you want to use.

Try this:

python3.9 -m pip install ta-lib

(Replace python3.9 with whichever Python you are using )

On Jan 7, 2021, at 7:04 AM, Emmanuel Iturbide [email protected] wrote:

 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 "", line 1, in File "/home/user/user/virtualenv/lib/python3.7/site-packages/talib/init.py", line 52, in 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.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

mrjbq7 avatar Jan 29 '21 03:01 mrjbq7

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

gotsteez avatar Jan 29 '21 03:01 gotsteez

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

leejh3224 avatar Feb 02 '21 11:02 leejh3224

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

xmatthias avatar Feb 02 '21 12:02 xmatthias

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?

dleclair avatar Feb 07 '21 19:02 dleclair

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

xmatthias avatar Feb 08 '21 07:02 xmatthias

@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)

DeWaRs1206 avatar May 06 '21 14:05 DeWaRs1206

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

ManuelSchneid3r avatar Sep 19 '21 22:09 ManuelSchneid3r

What’s the issue?

This Python project doesn’t require new numpy, although the C file that is checked in might be generated with new numpy.

Nothing stops using Cython to generate and install it with other numpy versions?

On Sep 19, 2021, at 3:26 PM, Manuel Schneider @.***> wrote:

 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

— 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 avatar Sep 20 '21 00:09 mrjbq7

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?

mripani avatar Nov 13 '21 17:11 mripani

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 avatar Nov 13 '21 17:11 mrjbq7

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.

mripani avatar Nov 13 '21 22:11 mripani

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.

mrjbq7 avatar Nov 15 '21 16:11 mrjbq7

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?

mripani avatar Jan 26 '22 02:01 mripani

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

mrjbq7 avatar Jan 26 '22 17:01 mrjbq7

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)

mrjbq7 avatar Jan 26 '22 17:01 mrjbq7

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.

keivanK1 avatar Mar 29 '22 18:03 keivanK1

I generate the C files using latest numpy and cython.

Maybe you need to regenerate them for your numpy version.

$ make cython $ python setup.py install

On Mar 29, 2022, at 11:43 AM, Keivan @.***> wrote:

 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 "", line 1, in File "/home/user/user/virtualenv/lib/python3.7/site-packages/talib/init.py", line 52, in 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.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

mrjbq7 avatar Mar 30 '22 00:03 mrjbq7

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

drmalabbasi avatar Jun 12 '22 00:06 drmalabbasi

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

dahlo avatar Oct 28 '22 21:10 dahlo