TA-Lib / ta-lib-python

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

New installation talib function call error #527

Closed gysmo8469 closed 2 years ago

gysmo8469 commented 2 years ago

Traceback (most recent call last): File "init.pxd", line 943, in numpy.import_array RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\vbtpro\rsi_demo.py", line 23, in rsi1 = vbt.talib('RSI').run(close_price)

Getting the error message above when attempting to run a talib RSI in the Basic RSI strategy tutorial. I'm using python 3.9.13 and Pycharm 2022.1.3, numpy 1.22.4, Visual studio 2015. I'm new to github posting and fairly new to python, sorry if I left something out . I get this message with and without import talib.

gysmo8469 commented 2 years ago

Solved the issue by manually installing numpy==1.22.4 first, then talib then vectorbt. Also used visual studio 2022 c++ in case anyone else is wondering if it works.

pranjal-joshi commented 1 year ago

Hi @gysmo8469

I am facing the same issue while building an executable using PyInstaller on GitHub actions.

Traceback (most recent call last):
  File "__init__.pxd", line [9](https://github.com/pranjal-joshi/Screeni-py/runs/8284650109?check_suite_focus=true#step:8:10)42, in numpy.import_array
RuntimeError: module compiled against API version 0x[10](https://github.com/pranjal-joshi/Screeni-py/runs/8284650109?check_suite_focus=true#step:8:11) but this version of numpy is 0xf

Can you explain in detail how did you fixed this?

mrjbq7 commented 1 year ago

Upgrade numpy, or manually install this module. I include the C files generated against the latest numpy as a convenience so that you don’t need to have a C compiler to install.

Perhaps I can generate them against an older numpy API, let me look into that.

On Sep 10, 2022, at 6:10 AM, Pranjal Joshi @.***> wrote:

 Hi @gysmo8469

I am facing the same issue while building an executable using PyInstaller on GitHub actions.

Traceback (most recent call last): File "init.pxd", line 942, in numpy.import_array RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf Can you explain in detail how did you fixed this?

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

pranjal-joshi commented 1 year ago

Hi @mrjbq7

Is it okay to use the latest numpy version while using ta-lib-0.4.0-src.tar.gz? (and further using pip install ta-lib)

Please take a look at my build script.

pip install numpy==1.21.0
cd .github/dependencies/
tar -xzf ta-lib-0.4.0-src.tar.gz
cd ta-lib/
./configure --prefix=/usr
make
sudo make install

UPDATE:

@mrjbq7 I've tried with the latest numpy 1.23.3 still getting the following error.

Traceback (most recent call last):
  File "__init__.pxd", line [9](https://github.com/pranjal-joshi/Screeni-py/runs/8285228112?check_suite_focus=true#step:8:10)42, in numpy.import_array
RuntimeError: module compiled against API version 0x[10](https://github.com/pranjal-joshi/Screeni-py/runs/8285228112?check_suite_focus=true#step:8:11) but this version of numpy is 0xf

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "screenipy.py", line 9, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "classes/Screener.py", line [12](https://github.com/pranjal-joshi/Screeni-py/runs/8285228112?check_suite_focus=true#step:8:13), in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "talib/__init__.py", line 93, in <module>
  File "talib/_func.pxi", line [15](https://github.com/pranjal-joshi/Screeni-py/runs/8285228112?check_suite_focus=true#step:8:16), in init talib._ta_lib
  File "__init__.pxd", line 944, in numpy.import_array
ImportError: numpy.core.multiarray failed to import

Note that I'm using tensorflow==2.9.2 along with ta-lib. Before adding tensorflow-based code to my script, numpy==1.21.0 was working fine with ta-lib==0.4.24

pranjal-joshi commented 1 year ago

Hi @mrjbq7

I've resolved this issue with the following environment configuration. I am sharing here if someone faces the same issue. 😄

numpy==1.21.0
TA_Lib-0.4.19(Windows)/ta-lib==0.4.24(Linux)/ta-lib==0.4.24(MacOS)
tensorflow==2.9.2
mrjbq7 commented 1 year ago

https://stackoverflow.com/questions/33859531/runtimeerror-module-compiled-against-api-version-a-but-this-version-of-numpy-is/39339975#39339975

On Jul 6, 2022, at 8:30 AM, gysmo8469 @.***> wrote:

RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf

mrjbq7 commented 1 year ago

I’ve been testing it with the latest 1.23 series and everything is fine.

I didn’t realize this makes it so difficult to use older numpy.

On Sat, Sep 10, 2022 at 7:08 AM Pranjal Joshi @.***> wrote:

Hi @mrjbq7 https://github.com/mrjbq7

Is it okay to use the latest numpy version while using ta-lib-0.4.0-src.tar.gz? (and further using pip install ta-lib)

Please take a look at my build script.

pip install numpy==1.21.0 cd .github/dependencies/ tar -xzf ta-lib-0.4.0-src.tar.gz cd ta-lib/ ./configure --prefix=/usr make sudo make install

— Reply to this email directly, view it on GitHub https://github.com/mrjbq7/ta-lib/issues/527#issuecomment-1242737239, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF5A23D5PMADUX355EXETV5SI7BANCNFSM52YMIZEQ . You are receiving this because you were mentioned.Message ID: @.***>

mrjbq7 commented 1 year ago

What do you mean you get this warning without “import talib”?

On Wed, Jul 6, 2022 at 8:30 AM gysmo8469 @.***> wrote:

Traceback (most recent call last): File "init.pxd", line 943, in numpy.import_array RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\vbtpro\rsi_demo.py", line 23, in rsi1 = vbt.talib('RSI').run(close_price)

Getting the error message above when attempting to run a talib RSI in the Basic RSI strategy tutorial. I'm using python 3.9.13 and Pycharm 2022.1.3, numpy 1.22.4, Visual studio

  1. I'm new to github posting and fairly new to python, sorry if I left something out . I get this message with and without import talib.

— Reply to this email directly, view it on GitHub https://github.com/mrjbq7/ta-lib/issues/527, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF5A7K42U6XL7BK75UCTDVSUKXVANCNFSM52YMIZEQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

gysmo8469 commented 1 year ago

What do you mean you get this warning without “import talib”?

On Wed, Jul 6, 2022 at 8:30 AM gysmo8469 @.***> wrote:

Traceback (most recent call last): File "init.pxd", line 943, in numpy.import_array RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\vbtpro\rsi_demo.py", line 23, in rsi1 = vbt.talib('RSI').run(close_price)

Getting the error message above when attempting to run a talib RSI in the Basic RSI strategy tutorial. I'm using python 3.9.13 and Pycharm 2022.1.3, numpy 1.22.4, Visual studio

  1. I'm new to github posting and fairly new to python, sorry if I left something out . I get this message with and without import talib.

— Reply to this email directly, view it on GitHub https://github.com/mrjbq7/ta-lib/issues/527, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF5A7K42U6XL7BK75UCTDVSUKXVANCNFSM52YMIZEQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

So if I remember correctly. Even when I didn't use the import talib instruction at the top of my python script, I was still getting this error. That kind of led me to suspect it was a prerequisite error. In this case the numpy install was the issue. Not sure why. But a manual install solved it.