TA-Lib / ta-lib-python

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

Symbol not found: _TA_ACOS error #408

Closed GeoMicroSoares closed 3 years ago

GeoMicroSoares commented 3 years ago

Hi there,

Trying to run freqtrader and getting a weird error that I can't find a solution for - just wondering if you'd have an idea of what might be going on around here.

The output I'm getting from my command is

2021-03-28 14:35:34,198 - freqtrade.resolvers.iresolver - WARNING - Could not import /Users/andre/freqtrade/user_data/strategies/bbrsi.py due to 'dlopen(/Users/andre/freqtrade/.env/lib/python3.9/site-packages/talib/_ta_lib.cpython-39-darwin.so, 2): Symbol not found: _TA_ACOS
  Referenced from: /Users/andre/freqtrade/.env/lib/python3.9/site-packages/talib/_ta_lib.cpython-39-darwin.so
  Expected in: flat namespace
 in /Users/andre/freqtrade/.env/lib/python3.9/site-packages/talib/_ta_lib.cpython-39-darwin.so'

I'm not sure what's going on so please let me know what other information you need. Thanks in advance!

mrjbq7 commented 3 years ago

Sounds like the installation had an error when you did “pip install ta-lib” or “python setup.py install”.

I would try to do that and see what the build error is.

On Mar 28, 2021, at 5:51 AM, André Soares @.***> wrote:

 Hi there,

Trying to run freqtrader and getting a weird error that I can't find a solution for - just wondering if you'd have an idea of what might be going on around here.

The output I'm getting from my command is

2021-03-28 14:35:34,198 - freqtrade.resolvers.iresolver - WARNING - Could not import /Users/andre/freqtrade/user_data/strategies/bbrsi.py due to 'dlopen(/Users/andre/freqtrade/.env/lib/python3.9/site-packages/talib/_ta_lib.cpython-39-darwin.so, 2): Symbol not found: _TA_ACOS Referenced from: /Users/andre/freqtrade/.env/lib/python3.9/site-packages/talib/_ta_lib.cpython-39-darwin.so Expected in: flat namespace in /Users/andre/freqtrade/.env/lib/python3.9/site-packages/talib/_ta_lib.cpython-39-darwin.so' I'm not sure what's going on so please let me know what other information you need. Thanks in advance!

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

trapprakam commented 3 years ago

I am experiencing the same issue after installing ta-lib for Mac M1 with arm64.


ImportError: dlopen(/Users/rakimtrappjackson/anaconda3/lib/python3.8/site-packages/TA_Lib-0.4.19-py3.8-macosx-10.9-x86_64.egg/talib/_ta_lib.cpython-38-darwin.so, 2): Symbol not found: _TA_ACOS
  Referenced from: /Users/rakimtrappjackson/anaconda3/lib/python3.8/site-packages/TA_Lib-0.4.19-py3.8-macosx-10.9-x86_64.egg/talib/_ta_lib.cpython-38-darwin.so
  Expected in: flat namespace
 in /Users/rakimtrappjackson/anaconda3/lib/python3.8/site-packages/TA_Lib-0.4.19-py3.8-macosx-10.9-x86_64.egg/talib/_ta_lib.cpython-38-darwin.so```
mrjbq7 commented 3 years ago

Have you tried the recommended installation procedure again?

And properly uninstalling first?

On Mar 31, 2021, at 5:07 AM, Rakim Trapp-Jackson @.***> wrote:

 I am experiencing the same issue after installing ta-lib for Mac M1 with arm64.

ImportError: dlopen(/Users/rakimtrappjackson/anaconda3/lib/python3.8/site-packages/TA_Lib-0.4.19-py3.8-macosx-10.9-x86_64.egg/talib/_ta_lib.cpython-38-darwin.so, 2): Symbol not found: _TA_ACOS Referenced from: /Users/rakimtrappjackson/anaconda3/lib/python3.8/site-packages/TA_Lib-0.4.19-py3.8-macosx-10.9-x86_64.egg/talib/_ta_lib.cpython-38-darwin.so Expected in: flat namespace in /Users/rakimtrappjackson/anaconda3/lib/python3.8/site-packages/TA_Lib-0.4.19-py3.8-macosx-10.9-x86_64.egg/talib/_ta_lib.cpython-38-darwin.so``` — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

trapprakam commented 3 years ago

Have you tried the recommended installation procedure again? And properly uninstalling first? On Mar 31, 2021, at 5:07 AM, Rakim Trapp-Jackson @.***> wrote:  I am experiencing the same issue after installing ta-lib for Mac M1 with arm64. ImportError: dlopen(/Users/rakimtrappjackson/anaconda3/lib/python3.8/site-packages/TA_Lib-0.4.19-py3.8-macosx-10.9-x86_64.egg/talib/_ta_lib.cpython-38-darwin.so, 2): Symbol not found: _TA_ACOS Referenced from: /Users/rakimtrappjackson/anaconda3/lib/python3.8/site-packages/TA_Lib-0.4.19-py3.8-macosx-10.9-x86_64.egg/talib/_ta_lib.cpython-38-darwin.so Expected in: flat namespace in /Users/rakimtrappjackson/anaconda3/lib/python3.8/site-packages/TA_Lib-0.4.19-py3.8-macosx-10.9-x86_64.egg/talib/_ta_lib.cpython-38-darwin.so``` — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

Hi,

Yes I first performed un-installs as follow: brew uninstall ta-lib pip uninstall ta-lib

Then I followed the instructions in the ReadMe: arch -arm64 brew install ta-lib export TA_INCLUDE_PATH="$(brew --prefix ta-lib)/include" export TA_LIBRARY_PATH="$(brew --prefix ta-lib)/lib" pip install TA-Lib

Successfully installed, then when I ran my script I received the same error.

mrjbq7 commented 3 years ago

Is your pip running a Rosetta emulated Python?

On Wed, Mar 31, 2021 at 11:09 AM Rakim Trapp-Jackson < @.***> wrote:

Have you tried the recommended installation procedure again? And properly uninstalling first? … <#m2598991601899915751> On Mar 31, 2021, at 5:07 AM, Rakim Trapp-Jackson @.***> wrote:  I am experiencing the same issue after installing ta-lib for Mac M1 with arm64. ImportError: dlopen(/Users/rakimtrappjackson/anaconda3/lib/python3.8/site-packages/TA_Lib-0.4.19-py3.8-macosx-10.9-x8664.egg/talib/ ta_lib.cpython-38-darwin.so, 2): Symbol not found: _TA_ACOS Referenced from: /Users/rakimtrappjackson/anaconda3/lib/python3.8/site-packages/TA_Lib-0.4.19-py3.8-macosx-10.9-x8664.egg/talib/ ta_lib.cpython-38-darwin.so Expected in: flat namespace in /Users/rakimtrappjackson/anaconda3/lib/python3.8/site-packages/TA_Lib-0.4.19-py3.8-macosx-10.9-x8664.egg/talib/ ta_lib.cpython-38-darwin.so``` — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

Hi,

Yes I first performed un-installs as follow: brew uninstall ta-lib pip uninstall ta-lib

Then I followed the instructions in the ReadMe: arch -arm64 brew install ta-lib export TA_INCLUDE_PATH="$(brew --prefix ta-lib)/include" export TA_LIBRARY_PATH="$(brew --prefix ta-lib)/lib" pip install TA-Lib

Successfully installed, then when I ran my script I received the same error.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/mrjbq7/ta-lib/issues/408#issuecomment-811298922, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF5A3HYBKQL7WXKZA4WRTTGNQMFANCNFSM4Z6AGLPA .

trapprakam commented 3 years ago

Is your pip running a Rosetta emulated Python? On Wed, Mar 31, 2021 at 11:09 AM Rakim Trapp-Jackson < @.> wrote: Have you tried the recommended installation procedure again? And properly uninstalling first? … <#m2598991601899915751> On Mar 31, 2021, at 5:07 AM, Rakim Trapp-Jackson @.> wrote:  I am experiencing the same issue after installing ta-lib for Mac M1 with arm64. ImportError: dlopen(/Users/rakimtrappjackson/anaconda3/lib/python3.8/site-packages/TA_Lib-0.4.19-py3.8-macosx-10.9-x8664.egg/talib/ ta_lib.cpython-38-darwin.so, 2): Symbol not found: _TA_ACOS Referenced from: /Users/rakimtrappjackson/anaconda3/lib/python3.8/site-packages/TA_Lib-0.4.19-py3.8-macosx-10.9-x8664.egg/talib/ ta_lib.cpython-38-darwin.so Expected in: flat namespace in /Users/rakimtrappjackson/anaconda3/lib/python3.8/site-packages/TA_Lib-0.4.19-py3.8-macosx-10.9-x8664.egg/talib/ ta_lib.cpython-38-darwin.so``` — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Hi, Yes I first performed un-installs as follow: brew uninstall ta-lib pip uninstall ta-lib Then I followed the instructions in the ReadMe: arch -arm64 brew install ta-lib export TA_INCLUDE_PATH="$(brew --prefix ta-lib)/include" export TA_LIBRARY_PATH="$(brew --prefix ta-lib)/lib" pip install TA-Lib Successfully installed, then when I ran my script I received the same error. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#408 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF5A3HYBKQL7WXKZA4WRTTGNQMFANCNFSM4Z6AGLPA .

I will have to check. I am running Python installed via Conda. Python 3.8 located in my anaconda3/bin folder.

tuomijal commented 3 years ago

I am experiencing this same issue on M1 Mac.

Could not import /Users/jalmarituominen/fun/freqtrade/user_data/strategies/fixed_riskreward_loss.py due to 'dlopen(/Users/jalmarituominen/fun/ta-lib/talib/_ta_lib.cpython-38-darwin.so, 2): Symbol not found: _TA_ACOS
  Referenced from: /Users/jalmarituominen/fun/ta-lib/talib/_ta_lib.cpython-38-darwin.so
  Expected in: flat namespace

I am running Python 3.8. so I suppose that has to be rosetta emulated:

▶ python
Python 3.8.8 (default, Feb 24 2021, 13:46:16)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin

I tried installing with pip install ta-lib and pip install -e . Neither of these throw an error but the problem persists. TA-Lib is installed using brew like so:

▶ brew --version
Homebrew 3.0.11

arch -arm64 brew install ta-lib
export TA_INCLUDE_PATH="$(brew --prefix ta-lib)/include"
export TA_LIBRARY_PATH="$(brew --prefix ta-lib)/lib"
haenenma commented 3 years ago

Same issue with mac M1 too...

emanuellabat commented 3 years ago

Hi,

Anyone have any idea about what's the problem? I uninstall and install again, but the problem persists.

mrjbq7 commented 3 years ago

Every time this has happened, it's been because of two reasons:

1) mixed environments (python3 was x86_64 but trying to switch over to native arm64 builds of everything), or Homebrew was still the old location in /usr/local and not the "M1 native" location in /opt/homebrew...

2) "pip" installed to a different python than the one you want to run from.

To fix the second point, you should first pip uninstall ta-lib, and then when you install, use pip from the python you want to use:

$ python3 -m pip install ta-lib
$ 
$ python3
>>> import talib

I can assure you that it all works just fine, but might require (because of a numpy build issue), a newer version of setuputils that ships with the newer python 3.9 builds from homebrew.

emanuellabat commented 3 years ago

Hello,

I did averything that @mrjbq7 said but the problem still. Anyone could fix the problem? @mrjbq7 are you using TA-Lib in Mac M1?

Thanks

mrjbq7 commented 3 years ago

Yes, I develop now primarily on MacBook M1 and it works great.

Every case where it fails has so far been configuration issues with Rosetta and/or homebrew and mixed Python versions.

On Apr 19, 2021, at 3:54 PM, Emanuel Labat @.***> wrote:

 Hello,

I did averything that @mrjbq7 said but the problem still. Anyone could fix the problem? @mrjbq7 are you using TA-Lib in Mac M1?

Thanks

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

emanuellabat commented 3 years ago

Okkk great, You are a luchy person jaaa. I'm using conda base and python 3.8.5 64-bit. Python 3.8.5 64-bit ('base':conda) ~/opt/anaconda3/bin/python

Captura de Pantalla 2021-04-19 a la(s) 20 31 18

Sorry, but I don't know what Rosetta is.

What Python version are you using? @mrjbq7

Thanks

mrjbq7 commented 3 years ago

Some ideas, here's what I would try if I were you.

I suspect, particularly with so many python versions that pip3 (when doing pip3 install ta-lib) is linked to a different python version than the one you want to use...

Open a Terminal.

# get rid of the old ta-lib python
$ pip3 uninstall ta-lib

# make sure your ta-lib C library is proper architecture (arm64)
$ file $(brew --prefix ta-lib)/lib/libta_lib.dylib

# make sure your python is the proper architecture (arm64)
$ file ~/opt/anaconda3/bin/python

# install ta-lib using your desired python
$ ~/opt/anaconda3/bin/python -m pip install ta-lib

# start python and see if it worked
$ ~/opt/anaconda3/bin/python
>>> import talib
>>> print(talib.__ta_version__)

I use the homebrew python 3.9.4 cleanly installed using homebrew in /opt/homebrew and everything installed for arm64 native architecture.

Rosetta2 is the translation layer that allows x86_64 apps to run on Apple Silicon.

tuomijal commented 3 years ago

Thank you @mrjbq7 for in detail advice on this. The issue was indeed caused by python running x86_64 and everything else running arm64. After installing everything with miniforge things started working like a charm, thanks!

aitor848 commented 3 years ago

Hi @mrjbq7 I am having the same issue:

My program crashed when i imported ta-lib.

I tried to install python natively in /opt/.. with this command: brew install python@3.9

Everything went fine but when I check again with file $(which python3.9), I still have the the other path python version so I believe it is still working with the emulated version. I have the ta-lib C library in the arm64 architecture.

What can I do? I develop using a virtual env in visual studio code. How can I have everything in arm architecture in my venv?

Thank you so much! 😃

mrjbq7 commented 3 years ago

Best option would be to remove the old python version, second best option would be to put the new one at the head of the PATH so it is found first:

$ export PATH="/opt/homebrew/bin:${PATH}"

Or maybe just python3:

$ export PATH="$(brew --prefix python@3.9)/bin:${PATH}"
isaaccwb commented 3 years ago

Hello sir,

I have above error too and i try all method could find that could not be resolved.

Is it a problem my anaconda3 python is not running in ARM? How to fix it?

(base) isaaccheng@Isaacs-MacBook-Pro ~ % file ~/opt/anaconda3/bin/python /Users/isaaccheng/opt/anaconda3/bin/python: Mach-O 64-bit executable x86_64

Thanks A lot in advanced

aitor848 commented 3 years ago

Thank you so much @mrjbq7 it works!! Now when i run the command file $(which python3.9) it returns: /opt/homebrew/bin/python3.9: Mach-O 64-bit executable arm64

So now I should have installed both python and Ta-lib c library in arm architecture, haven't I? How can I install a venv with python and talib homebrew(arm architecture)? If i do that now it is supposed that my programs will run now. (??) I work with VSCode and everytime I create a new project, I have a fresh python and libraries versions.

Thank you so much!

aitor848 commented 3 years ago

> Hello sir,

I have above error too and i try all method could find that could not be resolved.

Is it a problem my anaconda3 python is not running in ARM? How to fix it?

(base) isaaccheng@Isaacs-MacBook-Pro ~ % file ~/opt/anaconda3/bin/python /Users/isaaccheng/opt/anaconda3/bin/python: Mach-O 64-bit executable x86_64

Thanks A lot in advanced

You should have your libraries running with Rosetta, so all your libraries must be in a _executable x8664.

You can check it here: @mrjbq7 explains it 👉🏼 https://github.com/mrjbq7/ta-lib/issues/381

Another link with info, so you can try: 👉🏼 https://stackoverflow.com/questions/66056725/is-it-possible-that-mac-m1-users-are-not-able-to-use-python-wrapper-for-ta-lib

isaaccwb commented 3 years ago

Hello @mrjbq7 thanks a lot for your explanation.

I tried all the possible ways that listed you explained on diff. threads and it is still does not work.

Ultimately, i did finally get it work by.........

i find my $ cat .bash_profile, I only got below shown

export PATH=“/usr/local/bin:PATH”

I dont see the Conda on my bash_profile , so i guess Anaconda install previously got issue. After this I reinstall Anaconda account and i finally i see

export PATH="/usr/local/bin:$PATH"

>>> conda initialize >>>

!! Contents within this block are managed by 'conda init' !!

conda_setup="$('/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)" if [ $? -eq 0 ]; then eval "$__conda_setup" else if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then . "/opt/anaconda3/etc/profile.d/conda.sh" else export PATH="/opt/anaconda3/bin:$PATH" fi fi unset conda_setup

<<< conda initialize <<<

I work all your solutions again but still does not work. However i do this, it works like magic....

$conda install -c conda-forge ta-lib

I am not sure why, but it is working finally to end my painful problem.

Cheers, Isaac

kartzke commented 3 years ago

Hi, thanks so much for the troubleshooting help in this thread. I'm getting the same error and haven't been able to resolve it. I'm on a MacBook Pro M1 / Apple Silicon. I do have both the Apple Silicon and x86 homebrews installed. Not sure if that might cause conflicts here.

This is the error I am getting:

could not import [PYTHON_FILE] due to 'dlopen(/Users/demo/miniforge3/envs/ft20210528_2/lib/python3.8/site-packages/talib/_ta_lib.cpython-38-darwin.so, 2): Symbol not found: _TA_ACOS Referenced from: /Users/demo/miniforge3/envs/ft20210528_2/lib/python3.8/site-packages/talib/_ta_lib.cpython-38-darwin.so Expected in: flat namespace in /Users/demo/miniforge3/envs/ft20210528_2/lib/python3.8/site-packages/talib/_ta_lib.cpython-38-darwin.so'

I tried the steps listed above and it looks like everything is running ARM64. Any other ideas to try?

Running...

$ pip3 uninstall ta-lib

Returns...

Found existing installation: TA-Lib 0.4.20 Uninstalling TA-Lib-0.4.20: Would remove: /Users/demo/miniforge3/envs/ft20210528_2/lib/python3.8/site-packages/TA_Lib-0.4.20.dist-info/ /Users/demo/miniforge3/envs/ft20210528_2/lib/python3.8/site-packages/talib/ Proceed (y/n)? y Successfully uninstalled TA-Lib-0.4.20

Running

$ file $(brew --prefix ta-lib)/lib/libta_lib.dylib

Returns...

/opt/homebrew/opt/ta-lib/lib/libta_lib.dylib: Mach-O 64-bit dynamically linked shared library arm64

Running...

$file ~/miniforge3/envs/ft20210528_2/bin/python

Returns...

/Users/demo/miniforge3/envs/ft20210528_2/bin/python: Mach-O 64-bit executable arm64

Running....

$ ~/miniforge3/envs/ft20210528_2/bin/python -m pip install ta-lib

Returns...

Collecting ta-lib Using cached TA_Lib-0.4.20-cp38-cp38-macosx_11_0_arm64.whl Requirement already satisfied: numpy in /Users/demo/miniforge3/envs/ft20210528_2/lib/python3.8/site-packages (from ta-lib) (1.20.3) Installing collected packages: ta-lib Successfully installed ta-lib-0.4.20

But running this...

$ ~/miniforge3/envs/ft20210528_2/bin/python

import talib

Returns this error:

Traceback (most recent call last): File "", line 1, in File "/Users/demo/miniforge3/envs/ft20210528_2/lib/python3.8/site-packages/talib/init.py", line 52, in from ._ta_lib import ( ImportError: dlopen(/Users/demo/miniforge3/envs/ft20210528_2/lib/python3.8/site-packages/talib/_ta_lib.cpython-38-darwin.so, 2): Symbol not found: _TA_ACOS Referenced from: /Users/demo/miniforge3/envs/ft20210528_2/lib/python3.8/site-packages/talib/_ta_lib.cpython-38-darwin.so Expected in: flat namespace in /Users/demo/miniforge3/envs/ft20210528_2/lib/python3.8/site-packages/talib/_ta_lib.cpython-38-darwin.so

kartzke commented 3 years ago

I did a bit more troubleshooting and haven't found a solution yet. One thing I tried that's worth noting: running brew doctor gives me this output. I renamed the two files in /usr/local/ to see if that would help by removing potential homebrew conflicts, but it didn't help.

brew doctor

Please note that these warnings are just used to help the Homebrew maintainers with debugging if you file an issue. If everything you use Homebrew for is working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories. ./configure scripts often look for *-config scripts to determine if software packages are installed, and which additional flags to use when compiling and linking.

Having additional scripts in your path can confuse software installed via Homebrew if the config script overrides a system or Homebrew-provided script of the same name. We found the following "config" scripts: /Users/demo/miniforge3/envs/ft20210528_2/bin/krb5-config /Users/demo/miniforge3/envs/ft20210528_2/bin/freetype-config /Users/demo/miniforge3/envs/ft20210528_2/bin/libpng16-config /Users/demo/miniforge3/envs/ft20210528_2/bin/libpng-config /Users/demo/miniforge3/envs/ft20210528_2/bin/python3-config /Users/demo/miniforge3/envs/ft20210528_2/bin/curl-config /Users/demo/miniforge3/envs/ft20210528_2/bin/ncursesw6-config /Users/demo/miniforge3/envs/ft20210528_2/bin/ncurses6-config /Users/demo/miniforge3/envs/ft20210528_2/bin/python3.8-config /usr/local/bin/pkg-config /usr/local/bin/ta-lib-config

mrjbq7 commented 3 years ago

If you have files in /usr/local then you aren’t running ARM64 homebrew. The location for that would be under /opt.

It’s an issue with mixed architectures. Delete the old homebrew and embrace pure M1 homebrew hotness.

On May 30, 2021, at 7:09 PM, Ryan @.***> wrote:

 I did a bit more troubleshooting and haven't found a solution yet. One thing I tried that's worth noting: running brew doctor gives me this output. I renamed the two files in /usr/local/ to see if that would help by removing potential homebrew conflicts, but it didn't help.

brew doctor

Please note that these warnings are just used to help the Homebrew maintainers with debugging if you file an issue. If everything you use Homebrew for is working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories. ./configure scripts often look for *-config scripts to determine if software packages are installed, and which additional flags to use when compiling and linking.

Having additional scripts in your path can confuse software installed via Homebrew if the config script overrides a system or Homebrew-provided script of the same name. We found the following "config" scripts: /Users/demo/miniforge3/envs/ft20210528_2/bin/krb5-config /Users/demo/miniforge3/envs/ft20210528_2/bin/freetype-config /Users/demo/miniforge3/envs/ft20210528_2/bin/libpng16-config /Users/demo/miniforge3/envs/ft20210528_2/bin/libpng-config /Users/demo/miniforge3/envs/ft20210528_2/bin/python3-config /Users/demo/miniforge3/envs/ft20210528_2/bin/curl-config /Users/demo/miniforge3/envs/ft20210528_2/bin/ncursesw6-config /Users/demo/miniforge3/envs/ft20210528_2/bin/ncurses6-config /Users/demo/miniforge3/envs/ft20210528_2/bin/python3.8-config /usr/local/bin/pkg-config /usr/local/bin/ta-lib-config

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

kartzke commented 3 years ago

@mrjbq7 haha, I think I am, I have both Homebrew architectures installed because I couldn't get my project to run without Rosetta emulation. So under a different macOS user, I'm running the project under Rosetta emulation with x86 Python. And I have a demo macOS user account with ARM64 python installed (mini forge).

To confirm, in the demo user account, running this:

$ file $(brew --prefix ta-lib)/lib/libta_lib.dylib

Returns...

/opt/homebrew/opt/ta-lib/lib/libta_lib.dylib: Mach-O 64-bit dynamically linked shared library arm64

Now, I'm not sure if there could be conflicts caused by having both Homebrew's installed. I can try uninstalling the x86 version, but that might bork my x86 projects.

mrjbq7 commented 3 years ago

I think my search path for TA_LIBRARY_PATH searches /usr before /opt. Perhaps I can change that, or you can modify the setup.py.

On May 30, 2021, at 7:30 PM, Ryan @.***> wrote:

 @mrjbq7 haha, I think I am, I have both Homebrew architectures installed because I couldn't get my project to run without Rosetta emulation. So under a different macOS user, I'm running the project under Rosetta emulation with x86 Python. And I have a demo macOS user account with ARM64 python installed (mini forge).

To confirm, in the demo user account, running this:

$ file $(brew --prefix ta-lib)/lib/libta_lib.dylib

Returns...

/opt/homebrew/opt/ta-lib/lib/libta_lib.dylib: Mach-O 64-bit dynamically linked shared library arm64

Now, I'm not sure if there could be conflicts caused by having both Homebrew's installed. I can try uninstalling the x86 version, but that might bork my x86 projects.

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

kartzke commented 3 years ago

@mrjbq7 thanks, you're right! I was able to install ta-lib from a local copy with a modified setup.py, and it all seems to work. So I've uninstalled Homebrew x86 version and am now 100% ARM. Woot woot!

A3-88 commented 3 years ago

Some ideas, here's what I would try if I were you.

I suspect, particularly with so many python versions that pip3 (when doing pip3 install ta-lib) is linked to a different python version than the one you want to use...

Open a Terminal.

# get rid of the old ta-lib python
$ pip3 uninstall ta-lib

# make sure your ta-lib C library is proper architecture (arm64)
$ file $(brew --prefix ta-lib)/lib/libta_lib.dylib

# make sure your python is the proper architecture (arm64)
$ file ~/opt/anaconda3/bin/python

# install ta-lib using your desired python
$ ~/opt/anaconda3/bin/python -m pip install ta-lib

# start python and see if it worked
$ ~/opt/anaconda3/bin/python
>>> import talib
>>> print(talib.__ta_version__)

I use the homebrew python 3.9.4 cleanly installed using homebrew in /opt/homebrew and everything installed for arm64 native architecture.

Rosetta2 is the translation layer that allows x86_64 apps to run on Apple Silicon.

Hi! My python arquitecture is: Mach-O 64-bit executable x86_64. How can I have it be on arm64??

Thanks!

SamTseng commented 3 years ago

After some struggle, I finally make ta-lib work! Here are my installation procedure: $ conda create -n finance python=3 $ conda activate finance $ brew install ta-lib $ conda install -c conda-forge ta-lib # do not use: pip install ta-lib Then: $ python Python 3.9.5 (default, May 18 2021, 12:31:01) [Clang 10.0.0 ] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information. ' >>> import talib ' ' >>> talib.__taversion_\ ' b'0.4.0 (Sep 29 2020 17:41:45)' It work! (that is, no more complain about Symbol not found: _TA_ACOS, and talib works!)

Below are more details on my MacBook Pro with M1 CPU: $ where brew /opt/homebrew/bin/brew (finance) $ conda list | grep ta-lib libta-lib 0.4.0 haf1e3a3_0 conda-forge ta-lib 0.4.19 py39h026c905_2 conda-forge (finance) $ pip list | grep ta-lib (finance) $

Guillaume6606 commented 3 years ago

After trying various ways to install TA-Lib on my M1, I finally managed to do it, mainly thanks to this issue. I'd like to add one thing: using --no-cache-dir flag when pip installing was essential for me as I had tried many different installs. So when reinstalling try: your-arm64-python -m pip install --no-cache-dir ta-lib

mrjbq7 commented 3 years ago

Thank you @Guillaume6606 !

Added this as a note in the README.

https://github.com/mrjbq7/ta-lib/commit/08bb812f34700f72836d091c6a530cff8787f2ba

nick-dolan commented 2 years ago

This works for me:

brew install ta-lib conda install -c conda-forge ta-lib

Thanks @SamTseng

CDLim0906 commented 2 years ago

@SamTseng Hi Sam thanks for all the steps, it works in my terminal but when I try to import and use it in Jupyter notebook I am unable to use it.

mrjbq7 commented 2 years ago

@CDLim0906 you probably are using different Python's in the terminal and the Jupyter setups.

CDLim0906 commented 2 years ago

$ conda install -c conda-forge ta-lib I retried using this step it works now :) thanks mrjbq7 I have gone thru this whole forum. Got it done now.

furkanbr commented 2 years ago

Im getting same error and tried everything at hier but didn't work. Do anyone have advice to me?

mrjbq7 commented 2 years ago

I don't use conda :shrug:

pranjal-joshi commented 2 years ago

08bb812

Hi @mrjbq7 I have tried installing it on my MacBook with M1 but the conda is throwing the following error

Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - ta-lib

Current channels:

  - https://conda.anaconda.org/conda-forge/osx-arm64
  - https://conda.anaconda.org/conda-forge/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

Please guide for installation.

mrjbq7 commented 2 years ago

I have no idea why it would not be available via conda. It is available on PyPI.

On Jun 14, 2022, at 7:20 AM, Pranjal Joshi @.***> wrote:

 08bb812

Hi @mrjbq7 I have tried installing it on my MacBook with M1 but the conda is throwing the following error

Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Collecting package metadata (repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  • ta-lib

Current channels:

To search for alternate channels that may provide the conda package you're looking for, navigate to

https://anaconda.org

and use the search bar at the top of the page. Please guide for installation.

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

fip17 commented 1 year ago

This installer worked for ta-lib on Apple Silicon Macbook Pro M2 2023: https://anaconda.org/conda-forge/libta-lib conda update -n base -c defaults conda conda install -c conda-forge libta-lib

All kinds of trouble getting brew and conda to play nice together.
Too many paths, confused python installations.
Settled on miniconda, iterm2, conda environments, python==3.9

42piratas commented 1 year ago

Hi there! I have read all the msg above but couldn't solve the issue yet. I don't use conda though, so I have skipped those alternatives. Which brings me to the question: is it possible to install ta-lib on M1s without Conda?

$ which python /opt/homebrew/bin/python3 $ which brew /opt/homebrew/bin/brew $ which pip /Library/Frameworks/Python.framework/Versions/3.11/bin/pip

I have followed step by steps this recommendation in particular, including uninstalling and reinstalling everything. But I still get the error...

image

Thanks in advance, I appreciate the help!

mrjbq7 commented 1 year ago

Thanks for the context -- so I don't recommend using pip since it probably refers to a different Python than /opt/homebrew/bin/python3. It looks like you have two versions of Python installed?

Regardless, I would

1) /opt/homebrew/bin/brew install ta-lib

2) /opt/homebrew/bin/python3 -m pip install ta-lib

3) /opt/homebrew/bin/python3 -c "import talib; print(talib.__version__)"

42piratas commented 1 year ago

I followed those steps but I still get the same error

image

mrjbq7 commented 1 year ago

Hmm, that's strange.

I wonder if you have an intel one installed alongside the arm64 one:

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

$ file /usr/local/homebrew/lib/libta_lib.dylib
...

The only other thing I could think is if you want to try installing from source, perhaps an error is being hidden?

$ git clone git@github.com:TA-Lib/ta-lib-python.git

$ cd ta-lib-python

$ /opt/homebrew/bin/python3 setup.py install
42piratas commented 1 year ago

It returns the same error even after uninstalling the previous versions and reinstalling with the source mentioned above

>>> import talib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/homebrew/lib/python3.11/site-packages/TA_Lib-0.4.26-py3.11-macosx-13-arm64.egg/talib/__init__.py", line 93, in <module>
    from ._ta_lib import (
ImportError: dlopen(/opt/homebrew/lib/python3.11/site-packages/TA_Lib-0.4.26-py3.11-macosx-13-arm64.egg/talib/_ta_lib.cpython-311-darwin.so, 0x0002): symbol not found in flat namespace '_TA_ACOS'
mrjbq7 commented 1 year ago

Do you have two version of libta_lib.dylib installed? One in /opt and the intel version in /usr/local?

mrjbq7 commented 1 year ago

I should note that I have an M1 macbook and it all works great for me, so there's gotta be some quirk to your setup.

42piratas commented 1 year ago

I have no doubt on that 😅

42piratas commented 1 year ago

@mrjbq7 could you please tell me if you have installed it WITHOUT Conda? Thx!

mrjbq7 commented 1 year ago

Yes, I don't use conda.

$ which python3.11
/opt/homebrew/opt/python@3.11/bin/python3.11

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

$ file /opt/homebrew/lib/python3.11/site-packages/talib/_ta_lib.cpython-311-darwin.so
/opt/homebrew/lib/python3.11/site-packages/talib/_ta_lib.cpython-311-darwin.so: Mach-O 64-bit bundle arm64

$ otool -L /opt/homebrew/lib/python3.11/site-packages/talib/_ta_lib.cpython-311-darwin.so
/opt/homebrew/lib/python3.11/site-packages/talib/_ta_lib.cpython-311-darwin.so:
    /opt/homebrew/opt/ta-lib/lib/libta_lib.0.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)

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