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

symbol not found in flat namespace '_TA_ACOS' #563

Closed Yktrcn closed 8 months ago

Yktrcn commented 1 year ago

I recently bought a Mac Pro with m2 chip. I installed pycharm and python 3.11.

To run my script I need ta-lib module.

i installed talib with pip and brew as well. But none of them worked. Also I searched for similar error on the net. I tried everything but none of them worked. I am really confused.

Traceback (most recent call last): File "/Users/*****/PycharmProjects/pythonProject/main.py", line 5, in import talib as ta File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/talib/init.py", line 93, in from ._ta_lib import ( ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/talib/_ta_lib.cpython-311-darwin.so, 0x0002): symbol not found in flat namespace '_TA_ACOS'

I changed the interpreter to 3.9 but it didn't work. Also I tried in virtual environment and local both but didn't work as well. I ran out of options. Hopefully someone can help me.

mrjbq7 commented 1 year ago

Is your brew installing ARM64 packages?Did you use “python3.11 -m pip install”?On Nov 20, 2022, at 5:14 AM, Yktrcn @.*> wrote: I recently bought a Mac Pro with m2 chip. I installed pycharm and python 3.11. To run my script I need ta-lib module. i installed talib with pip and brew as well. But none of them worked. Also I searched for similar error on the net. I tried everything but none of them worked. I am really confused. Traceback (most recent call last): File "/Users/***/PycharmProjects/pythonProject/main.py", line 5, in import talib as ta File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/talib/init.py", line 93, in from ._ta_lib import ( ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/talib/_ta_lib.cpython-311-darwin.so, 0x0002): symbol not found in flat namespace '_TA_ACOS' I changed the interpreter to 3.9 but it didn't work. Also I tried in virtual environment and local both but didn't work as well. I ran out of options. Hopefully someone can help me.

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

Yktrcn commented 1 year ago

How can i be sure that brew installs arm64 packages? I specified nothing in the beginning. After that i saw couple posts trying x86 packages which was for m1 chips. It didn’t work too

mrjbq7 commented 1 year ago

The short version is you can do $ which brewAnd if it’s in /usr it’s x86.64 and if it’s in /opt it’s ARM64. Also, You should be able to run “file” on the Ta-Lib C library to see what it was built with. There is no reason this wouldn’t support M2 or python 3.11, except an installation issue. On Nov 20, 2022, at 8:41 AM, Yktrcn @.***> wrote: How can i be sure that brew installs arm64 packages? I specified nothing in the beginning. After that i saw couple posts trying x86 packages which was for m1 chips. It didn’t work too

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

Yktrcn commented 1 year ago

Thanks for your help. Although I am newbie I am going step by step.

I opened a terminal and wrote where brew and here is the results: /opt/homebrew/bin/brew /usr/local/bin/brew

Does this might be the reason? There are two brews in my Mac?

mrjbq7 commented 1 year ago

Right, they can coexist to install Intel versions of software. But if you use python 3.11 native on apple silicon, you want to install and use the ARM64 packages using the /opt brew On Nov 20, 2022, at 9:29 AM, Yktrcn @.***> wrote: Thanks for your help. Although I am newbie I am going step by step. I opened a terminal and wrote where brew and here is the results: /opt/homebrew/bin/brew /usr/local/bin/brew Does this might be the reason? There are two brews in my Mac?

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

vedant17 commented 1 year ago

Hello @mrjbq7

I am facing a similar issue and I followed all the steps in this thread. I used

arch -arm64 brew install ta-lib to install the arm64 version. I'm still getting the same issue as above

mrjbq7 commented 1 year ago

You shouldn’t need to use arch -ARM64 if you are using brew installed natively in /opt. That kinda implies you have a mixed architecture system. Is the python3.11 that you are using Intel or apple silicon?

This library works great in Intel and apple silicon versions, can run in Rosetta and natively. Most of these issues are devops issues where you just have to match the architecture properly. I recommend clean ARM64 everything which means avoiding /usr homebrew and using /opt homebrew as long as you don’t need mixed architectures.

mrjbq7 commented 8 months ago

Closing old issue.

Zijun-Tang commented 7 months ago

@vedant17 Hi, did you solve your problem? I'm facing the same problem

mrjbq7 commented 7 months ago

Make sure all your architectures match.

It’s easy and simple when they do.

On Tue, Feb 13, 2024 at 8:33 PM Zijun-Tang @.***> wrote:

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

I am facing a similar issue and I followed all the steps in this thread. I used

arch -arm64 brew install ta-lib to install the arm64 version. I'm still getting the same issue as above

Hi, did you solve your problem? I'm facing the same problem

— Reply to this email directly, view it on GitHub https://github.com/TA-Lib/ta-lib-python/issues/563#issuecomment-1943066895, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF5A43MRQ2ZWVGJYMLCBDYTQ5ADAVCNFSM6AAAAAASF24ETWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBTGA3DMOBZGU . You are receiving this because you were mentioned.Message ID: @.***>

Zijun-Tang commented 7 months ago

How to match the architectures? When I write which brew in terminal, the result is: /opt/homebrew/bin/brew. What can I do next? Thank you! I'm using apple M1 and python 3.9

mrjbq7 commented 7 months ago
$ which brew
/opt/homebrew/bin/brew

$ brew install ta-lib

$ file $(brew --prefix ta-lib)/lib/libta_lib.dylib 
/opt/homebrew/opt/ta-lib/lib/libta_lib.dylib: Mach-O 64-bit dynamically linked shared library arm64

$ file $(which python3.11)
/opt/homebrew/opt/python@3.11/bin/python3.11: Mach-O 64-bit executable arm64

$ python3.11 -m pip install ta-lib

$ python3.11 -c "import talib; print(talib.__version__)"
0.4.28
Zijun-Tang commented 7 months ago

My result is same with yours until the last command. When I write python3.11 -c "import talib; print(talib.version)", the result is still: ImportError: dlopen(/opt/homebrew/lib/python3.11/site-packages/talib/_ta_lib.cpython-311-darwin.so, 0x0002): symbol not found in flat namespace '_TA_ACOS'

mrjbq7 commented 7 months ago

Have you tried pip uninstall and then reinstall?

On Tue, Feb 13, 2024 at 9:13 PM Zijun-Tang @.***> wrote:

My result is same with yours until the last command. When I write python3.11 -c "import talib; print(talib.version)", the result is still: ImportError: dlopen(/opt/homebrew/lib/python3.11/site-packages/talib/_ ta_lib.cpython-311-darwin.so, 0x0002): symbol not found in flat namespace '_TA_ACOS'

— Reply to this email directly, view it on GitHub https://github.com/TA-Lib/ta-lib-python/issues/563#issuecomment-1943093679, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF5AYTS55ONH5DEZRDAN3YTRBV5AVCNFSM6AAAAAASF24ETWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBTGA4TGNRXHE . You are receiving this because you were mentioned.Message ID: @.***>

Zijun-Tang commented 7 months ago

yes, the problem is still there

mrjbq7 commented 7 months ago

Do you also have ta-lib installed in /usr homebrew with Intel? Maybe it’s picking that one one firstOn Feb 13, 2024, at 9:22 PM, Zijun-Tang @.***> wrote: yes, the problem is still there

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

Zijun-Tang commented 7 months ago

How to see if I installed ta-lib in /usr homebrew with Intel?

mrjbq7 commented 7 months ago

In the README did you try setting these to force it to use the ARM64 one installed:$ export TA_INCLUDE_PATH="$(brew --prefix ta-lib)/include" $ export TA_LIBRARY_PATH="$(brew --prefix ta-lib)/lib" Set those and then run pip uninstall / reinstalll On Feb 13, 2024, at 9:31 PM, Zijun-Tang @.***> wrote: How to see if I installed ta-lib in /usr homebrew with Intel?

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

Zijun-Tang commented 7 months ago

When writting (export TA_INCLUDE_PATH="$(brew --prefix ta-lib)/include") and (export TA_LIBRARY_PATH="$(brew --prefix ta-lib)/lib") in terminal, they don't have results, right? Then I write: brew uninstall ta-lib brew install ta-lib python3.11 -m pip uninstall ta-lib python3.11 -m pip install ta-lib python3.11 -c "import talib; print(talib.version)" The result is still: symbol not found in flat namespace '_TA_ACOS'

mrjbq7 commented 7 months ago

I think you have an Intel version of TA-lib installed and it’s finding it firsthttps://github.com/TA-Lib/ta-lib-python/blob/master/setup.py#L29You can see it looks under /usr alsoOn Feb 13, 2024, at 9:53 PM, Zijun-Tang @.***> wrote: When writting (export TA_INCLUDE_PATH="$(brew --prefix ta-lib)/include") and (export TA_LIBRARY_PATH="$(brew --prefix ta-lib)/lib") in terminal, they don't have results, right? Then I write: brew uninstall ta-lib brew install ta-lib python3.11 -m pip uninstall ta-lib python3.11 -m pip install ta-lib python3.11 -c "import talib; print(talib.version)" The result is still: symbol not found in flat namespace '_TA_ACOS'

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

Zijun-Tang commented 7 months ago

When I write ls /usr/local/include in terminal, there's no result, does it mean I don't have Intel version of TA-lib installed?

mrjbq7 commented 7 months ago

I know you're probably learning and frustrated trying to fix this, but seriously, are there any ta-lib files under /usr is something you should learn how to do:

$ find /usr -name "*libta_lib*"
/usr/local/Cellar/ta-lib/0.4.0/lib/libta_lib.dylib
/usr/local/Cellar/ta-lib/0.4.0/lib/libta_lib.a
/usr/local/Cellar/ta-lib/0.4.0/lib/libta_lib.0.dylib
/usr/local/lib/libta_lib.dylib
/usr/local/lib/libta_lib.a
/usr/local/lib/libta_lib.0.dylib