TA-Lib / ta-lib-python

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

ta-lib on mac m1 #587

Closed wilker06 closed 1 year ago

wilker06 commented 1 year ago

I used and liked ta-lib on Mac m1 with python3.10. For some reason, I moved on to 3.11. Unfortunately, I could not make ta-lib running again. For example, applying WMA the error '... WMA not found in init' pops up. Could you kindly advise how to fix th issue.

mrjbq7 commented 1 year ago

Follow the directions in the README. $ python3.11 -m pip install ta-libMake sure the architectures match. On Mar 26, 2023, at 10:16 PM, wilker06 @.***> wrote: I used and liked ta-lib on Mac m1 with python3.10. For some reason, I moved on to 3.11. Unfortunately, I could not make ta-lib running again. For example, applying WMA the error '... WMA not found in init' pops up. Could you kindly advise how to fix th issue.

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

wilker06 commented 1 year ago

I tried everything recommended in readme ....

Ignoring this and running any code that include ta-lib import and a method with WMA, it ends up in a lengthy error message even if the method with WMA is not called. Traceback (most recent call last): File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevconsole.py", line 364, in runcode coro = func() ^^^^^^ File "", line 1, in File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 198, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc)

wilker06 commented 1 year ago

Another comment: most common is the message: ImportError: dlopen(/Users/.../GitHub/Trading/venv/lib/python3.11/site-packages/talib/_ta_lib.cpython-311-darwin.so, 0x0002): symbol not found in flat namespace '_TA_ACOS'

mrjbq7 commented 1 year ago

Sounds like a mixed architecture issue. You should uninstall it and reinstall. You shouldn’t need to arch -arm64 if brew is native in /opt.Instead of pycharm and the virtual env, just get it working in the terminal first. It’s 100% works and supported. On Mar 27, 2023, at 2:11 AM, wilker06 @.***> wrote: Another comment: most common is the message: ImportError: dlopen(/Users/.../GitHub/Trading/venv/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, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

wilker06 commented 1 year ago

Hi John,

I followed your advice to build a new, clear python application:

  1. I deleted all python packages, removed everything about python - using the terminal
  2. Reinstalled package python 3.10, ib_insync, ….
  3. Run simple test code in PyCharm:

    import talib as ta

    print('soso‘)

It ends up with the error:

Traceback (most recent call last): File "/Users/…/GitHub/Trading_310/test.py", line 1, in import talib as ta File "/Users/.../GitHub/Trading_310/venv/lib/python3.10/site-packages/talib/init.py", line 93, in from ._ta_lib import ( ImportError: dlopen(/Users/... /GitHub/Trading_310/venv/lib/python3.10/site-packages/talib/_ta_lib.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace ‚_TA_ACOS'

  1. Running the test code with the terminal.

Last login: Thu Mar 30 20:26:49 on ttys000 cd '/Users/... /GitHub/Trading_310/' && '/usr/local/bin/python3' '/Users/... /GitHub/Trading_310/test.py' && echo Exit status: $? && exit 1 ... @MBP-von-Kersten ~ % cd '/Users/... /GitHub/Trading_310/' && '/usr/local/bin/python3' '/Users/... /GitHub/Trading_310/test.py' && echo Exit status: $? && exit 1 Traceback (most recent call last): File "/Users/... /GitHub/Trading_310/test.py", line 1, in import talib as ta ModuleNotFoundError: No module named 'talib' ... @MBP-von-Kersten Trading_310 %

I attach also a screenshot of the pyCHharm Project window

Any idea? Thank you in advance for your kind advice!

Best regards,

Kersten

Am 27.03.2023 um 15:31 schrieb John Benediktsson @.***>:

Sounds like a mixed architecture issue. You should uninstall it and reinstall. You shouldn’t need to arch -arm64 if brew is native in /opt.Instead of pycharm and the virtual env, just get it working in the terminal first. It’s 100% works and supported. On Mar 27, 2023, at 2:11 AM, wilker06 @.***> wrote: Another comment: most common is the message: ImportError: dlopen(/Users/.../GitHub/Trading/venv/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, or unsubscribe.You are receiving this because you commented.Message ID: @.> — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.>

mrjbq7 commented 1 year ago

Have you tried:

# check that it's using ``/opt`` which is for arm64 builds

$ which brew
/opt/homebrew/bin/brew

$ brew install ta-lib
$ export TA_INCLUDE_PATH="$(brew --prefix ta-lib)/include"
$ export TA_LIBRARY_PATH="$(brew --prefix ta-lib)/lib"
$ python3.11 -m pip install ta-lib
wilker06 commented 1 year ago

Hi John,

I got it work again, found some Python traces from earlier installations, very deep at the system.

Kind regards

Kersten

Am 27.03.2023 um 15:31 schrieb John Benediktsson @.***>:

Sounds like a mixed architecture issue. You should uninstall it and reinstall. You shouldn’t need to arch -arm64 if brew is native in /opt.Instead of pycharm and the virtual env, just get it working in the terminal first. It’s 100% works and supported. On Mar 27, 2023, at 2:11 AM, wilker06 @.***> wrote: Another comment: most common is the message: ImportError: dlopen(/Users/.../GitHub/Trading/venv/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, or unsubscribe.You are receiving this because you commented.Message ID: @.***> — Reply to this email directly, view it on GitHub https://github.com/TA-Lib/ta-lib-python/issues/587#issuecomment-1485098176, or unsubscribe https://github.com/notifications/unsubscribe-auth/AV37BZNJAFXKT533Y4G3PVTW6GJE3ANCNFSM6AAAAAAWIJBVVY. You are receiving this because you authored the thread.

iKpoxa commented 3 months ago

here is what worked for me (Apple M2 Max, Sonoma 14.4)

python3.11 pip uninstall ta-lib

export HOMEBREW_PREFIX=/opt/homebrew #set to your homebrew prefix export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp" export CFLAGS="$CFLAGS -I/usr/local/opt/libomp/include" export CXXFLAGS="$CXXFLAGS -I/usr/local/opt/libomp/include" export LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/local/opt/libomp/lib -L/usr/local/opt/libomp/lib -lomp"

python3.11 -m pip install --no-cache-dir ta-lib

wilker06 commented 3 months ago

@iKpoxa: thank you for the advice. As I already wrote on Apr 7, 2023 I followed John's advice and got it work again. Works fine since!