TA-Lib / ta-lib-python

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

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

Closed Kammani closed 2 weeks ago

Kammani commented 3 months 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 3 months ago

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

You can restrict numpy<2

looker01202 commented 3 months ago

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

zunleashed commented 1 month 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

stucash commented 3 weeks ago

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.

mrjbq7 commented 3 weeks ago

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: @.***>

stucash commented 3 weeks ago

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.

mrjbq7 commented 3 weeks ago

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

mrjbq7 commented 2 weeks ago

Released ta-lib 0.5.0 with numpy 2.0 support.

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