TA-Lib / ta-lib-python

Python wrapper for TA-Lib (http://ta-lib.org/).
http://ta-lib.github.io/ta-lib-python
Other
9.56k stars 1.75k forks source link

numpy-2.0.1 and ta-lib-0.4.32 are compatible? #673

Open Kammani opened 1 month ago

Kammani commented 1 month ago

numpy-2.0.1 and ta-lib-0.4.32 are used . And tests.py is simple code as mentioned here .

import numpy as np import talib

Check the versions to confirm the installation

print("NumPy version:", np.version) print("TA-Lib version:", talib.version)

Example usage of TA-Lib

data = np.random.random(100) # Generate some random data sma = talib.SMA(data, timeperiod=10) # Calculate a simple moving average

print("Simple Moving Average:", sma)

And the following message and Error appeared upon execution of tests.py file . ————— Traceback (most recent call last): File "/Users/Documents//testv.py", line 2, in import talib File "/Users//Documents//venv/lib/python3.12/site-packages/talib/init.py", line 93, in 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 ——————-

Can you offer any solution ? Many thanks .

mrjbq7 commented 1 month ago

Currently, cython and thus this extension is not compatible with numpy>=2.

You can restrict numpy<2

looker01202 commented 1 month ago

Try numpy v1.26.4. This solved the problem for my venv.

Zinaction commented 4 days ago

I had the same issue on my Mac Air M2-chip "Try numpy v1.26.4. This solved the problem for my venv." This fixed my same problem.

I made a new venv to keep numpy 1.x separate from 2.x for my other projects. After having done 'brew install ta-lib' and 'pip install TA-Lib' I did the following:

pip unintall numpy pip cache purge (this line may not be necessary...) pip install numpy==1.26.4