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

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

Open Kammani opened this issue 1 year ago • 3 comments

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 .

Kammani avatar Aug 14 '24 21:08 Kammani

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

You can restrict numpy<2

mrjbq7 avatar Aug 15 '24 01:08 mrjbq7

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

looker01202 avatar Aug 26 '24 21:08 looker01202

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

zunleashed avatar Oct 02 '24 14:10 zunleashed

hope it's not a big trouble but can we update the dependency of numpy from "numpy *" to "numpy ^1.26.4" that'll help most people understand what's going on without asking.

qiuxiaomu avatar Nov 02 '24 23:11 qiuxiaomu

What change do you want?On Nov 2, 2024, at 4:39 PM, QiuxiaoMu @.***> wrote: hope it's not a big trouble but can we update the dependency of numpy from "numpy *" to "numpy ^1.26.4" that'll help most people understand what's going on without asking.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

mrjbq7 avatar Nov 03 '24 00:11 mrjbq7

What change do you want?On Nov 2, 2024, at 4:39 PM, QiuxiaoMu @.*> wrote: hope it's not a big trouble but can we update the dependency of numpy from "numpy " to "numpy ^1.26.4" that'll help most people understand what's going on without asking. —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.>

I might be wrong but with poetry's show command normally we'd see the dependencies specified by the package itself and my first impression was that it was in the hand of the maintainer, not peotry.

Here's what I see from poetry show ta-lib:

 name         : ta-lib                    
 version      : 0.4.32                    
 description  : Python wrapper for TA-Lib 

 dependencies
  - numpy *

Here's a little to no help one, as there's not even a dependency section, from poetry show polars:

 name         : pandas                                                                  
 version      : 2.2.3                                                                   
 description  : Powerful data structures for data analysis, time series, and statistics 

And here's a very helpful one, giving us specific version for each dependency, from poetry show pandas:

 name         : pandas                                                                  
 version      : 2.2.3                                                                   
 description  : Powerful data structures for data analysis, time series, and statistics 

dependencies
 - numpy >=1.26.0
 - python-dateutil >=2.8.2
 - pytz >=2020.1
 - tzdata >=2022.7

required by
 - alpaca-py >=1.5.3
 - backtesting >0.25.0
 - bokeh >=1.2
 - exchange-calendars >=1.5
 - nautilus_trader >=2.2.3,<3.0.0
 - pandas-datareader >=0.23
 - pandas-market-calendars >=1.1
 - pyti *
 - seaborn >=1.2
 - statsmodels >=1.4,<2.1.0 || >2.1.0

I am not saying I wanted the change, I was just thinking at least for people using poetry it'll be easier for them to find out that ta-lib has a specific dependency on numpy and they don't have raise new issue just for the sake of duplication.

qiuxiaomu avatar Nov 04 '24 10:11 qiuxiaomu

That’s odd because I thought it was specified as numpy<2 everywhere.

mrjbq7 avatar Nov 04 '24 12:11 mrjbq7

Released ta-lib 0.5.0 with numpy 2.0 support.

Also released ta-lib 0.4.33 with numpy<2.0 support.

mrjbq7 avatar Nov 13 '24 17:11 mrjbq7