Tensorflow 2.6.0 and TA-lib 0.4.21 numpy version collision
Asked Answered
S

4

6

I'm trying to use both TA-lib version 0.4.21 and Tensorflow 2.6.0 in the same project. Both require different numpy versions: TF ~= 1.19.2 TA-lib >= 1.19.4

Given those dependencies, numpy 1.19.4 or 1.19.5 should work just fine, but I get the following exception:

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

I tried uninstalling and installing numpy 1.19.4 and 1.19.5 several times, on python 3.8 and 3.9 but the result is the same.

Removing TF and using latest version on numpy resolves the issue - but this isn't a solution for me.

Didn't find anything online about this collision between the two libraries.

Will be glad for help, thanks!

Sarcoid answered 13/8, 2021 at 17:32 Comment(2)
As per the latest release of Tensorflow version 2.6 supports numpy 1.19.5. Can you share the code snippet to reproduce the issue. Thanks!Harshman
The code is crashing on importsSarcoid
J
2

Try to install numpy first with:

pip install numpy==1.19.5 # This the TF version. 

Than compile and install TA-lib:

# downloag tar.gz file
./configure
make
make install

pip install TA-lib --no-binary TA-lib

You will rebuild the package with the outdated numpy C API usage.

It worked here in ubuntu 20.04.

Justificatory answered 17/11, 2021 at 12:15 Comment(0)
G
0

I also encountered the same problem as you. I reinstalled numpy after installing TA-Lib 0.4.21 and tensorflow 2.6.0. Commands used: pip install -U numpy & pip install numpy. Now my current version of numpy is still 1.21.2, but it seems that the version collision no longer exists.

Garpike answered 31/8, 2021 at 9:57 Comment(0)
A
0

If you are on m1, you can try install ta-lib with no-binary options through pip. In this way, you will compile the package from the source instead of using the wheel online.

pip install TA-lib --no-binary :all:

Or if you already installed TA-lib before:

pip install TA-lib --force-reinstall --no-binary :all:

It worked for me on M1 Macbook Pro with tensorFlow-deps==2.6.0

Alfreda answered 26/12, 2021 at 8:49 Comment(0)
S
0

Crispy Holiday, i faced the same problem like yours. I tried a lot, but this worked to me:

I'm using MacOs 10.13, first i installed tensorflow 2.6.5 (that requires numpy 1.19.5), when i install ta-lib 0.4.25 (that require numpy 1.24), i face errors, i cant import the two modules in a same file... so i installed another version of talib (0.4.24), and works!

Try:

 pip install tensorflow==2.6.5 ta-lib==0.4.24

Probably one of the old version will work with tensorflow.

Speechmaker answered 20/12, 2022 at 17:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.