Talib Library weird behavior
CbroLab opened this issue · 3 comments
Describe the current behavior
I was trying to run my notebook with talib library depency last night and got this weird bug.
RuntimeError Traceback (most recent call last)
__init__.pxd in numpy.import_array()
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf . Check the section C-API incompatibility at the Troubleshooting ImportError section at https://numpy.org/devdocs/user/troubleshooting-importerror.html#c-api-incompatibility for indications on how to solve this problem .
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
[<ipython-input-1-6eda0644b244>](https://localhost:8080/#) in <cell line: 7>()
5 get_ipython().system('dpkg -i libta.deb ta.deb')
6 get_ipython().system('pip install ta-lib')
----> 7 import talib
[/usr/local/lib/python3.9/dist-packages/talib/__init__.py](https://localhost:8080/#) in <module>
91
92
---> 93 from ._ta_lib import (
94 _ta_initialize, _ta_shutdown, MA_Type, __ta_version__,
95 _ta_set_unstable_period as set_unstable_period,
talib/_func.pxi in init talib._ta_lib()
__init__.pxd in numpy.import_array()
ImportError: numpy.core.multiarray failed to import
Everything is fine from last weekend, and I didn't use colab since yesterday and found this bug yesterday night. The way I am trying to install talib is
!wget https://launchpad.net/~mario-mariomedina/+archive/ubuntu/talib/+files/libta-lib0_0.4.0-oneiric1_amd64.deb -qO libta.deb
!wget https://launchpad.net/~mario-mariomedina/+archive/ubuntu/talib/+files/ta-lib0-dev_0.4.0-oneiric1_amd64.deb -qO ta.deb
!dpkg -i libta.deb ta.deb
!pip install ta-lib
import talib as ta
I searched this problem in stackoverflow and chatgpt, both gave my solution by downgrading numpy to some older versions but it didn't fix the issue. Then I checked fallback runtime and everything worked perfectly. Numpy version in both runtime are the same -- 1.22.4
Describe the expected behavior
A clear and concise explanation of what you expected to happen.
talib lib should be imported correctly
What web browser you are using
(Chrome, Firefox, Safari, etc.)
Chrome
Additional context
Link to a minimal, public, self-contained notebook that reproduces this issue.
- Share the file using your GitHub account using File > Save a copy as a GitHub Gist.
- or Share Drive notebooks using the Share button then 'Get Shareable Link'.
cc: @metrizable
@CbroLab Thanks for reporting the issue. I suspect, based on your reported error, that there is an incompatibility with the pre-compiled libraries in the deb files distributed in the mario-mariomedina
archive and/or talib wheel in PyPI. You may want to reach out to the maintainers of those deb files and/or the Python package.
I dug a little further and following along with the TA-lib documentation, although YMMV, I'm able to successfully install and import talib
when I compile from source:
%%shell
wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
tar -xzf ta-lib-0.4.0-src.tar.gz
cd ta-lib/
./configure --prefix=/usr
make
sudo make install
python -m pip install git+https://github.com/TA-Lib/ta-lib-python.git@TA_Lib-0.4.26
Huge thanks for @metrizable thank you for helping us many times!! This worked on my colab! But we do wanna request to make old runtime to be permant option like for different python versions this will make our life way easier that we will not face this situation again. Its extremely painful when you get up and find every worked perfect last night dead:-( However, we all love colab its the best python notebook experience ever in this world! Keep grinding!