Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbol not found: _TA_ACOS error #408

Closed
GeoMicroSoares opened this issue Mar 28, 2021 · 60 comments
Closed

Symbol not found: _TA_ACOS error #408

GeoMicroSoares opened this issue Mar 28, 2021 · 60 comments

Comments

@GeoMicroSoares
Copy link

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
Copy link
Collaborator

mrjbq7 commented Mar 28, 2021 via email

@trapprakam
Copy link

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
Copy link
Collaborator

mrjbq7 commented Mar 31, 2021 via email

@trapprakam
Copy link

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
Copy link
Collaborator

mrjbq7 commented Mar 31, 2021 via email

@trapprakam
Copy link

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? … <#m_2598991601899915751_> 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. — 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
Copy link

tuomijal commented Apr 11, 2021

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
Copy link

Same issue with mac M1 too...

@emanuellabat
Copy link

Hi,

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

@mrjbq7
Copy link
Collaborator

mrjbq7 commented Apr 12, 2021

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
Copy link

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
Copy link
Collaborator

mrjbq7 commented Apr 19, 2021 via email

@emanuellabat
Copy link

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
Copy link
Collaborator

mrjbq7 commented Apr 20, 2021

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
Copy link

tuomijal commented Apr 24, 2021

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
Copy link

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
Copy link
Collaborator

mrjbq7 commented May 11, 2021

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
Copy link

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
Copy link

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
Copy link

aitor848 commented May 11, 2021

> 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 x86_64.

You can check it here:
@mrjbq7 explains it 👉🏼 #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
Copy link

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
Copy link

kartzke commented May 28, 2021

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
Copy link

kartzke commented May 31, 2021

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
Copy link
Collaborator

mrjbq7 commented May 31, 2021 via email

@kartzke
Copy link

kartzke commented May 31, 2021

@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
Copy link
Collaborator

mrjbq7 commented May 31, 2021 via email

@kartzke
Copy link

kartzke commented Jun 1, 2021

@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
Copy link

A3-88 commented Jun 2, 2021

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
Copy link

SamTseng commented Jun 6, 2021

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.__ta_version__ '
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) $

@mrjbq7 mrjbq7 closed this as completed Sep 2, 2021
@nick-dolan
Copy link

This works for me:

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

Thanks @SamTseng

@CDLim0906
Copy link

@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
Copy link
Collaborator

mrjbq7 commented Dec 15, 2021

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

@CDLim0906
Copy link

$ 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
Copy link

furkanbr commented Apr 12, 2022

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

@mrjbq7
Copy link
Collaborator

mrjbq7 commented Apr 12, 2022

I don't use conda 🤷

@pranjal-joshi
Copy link

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
Copy link
Collaborator

mrjbq7 commented Jun 14, 2022 via email

@fip17
Copy link

fip17 commented Jan 28, 2023

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
Copy link

42piratas commented Feb 24, 2023

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
Copy link
Collaborator

mrjbq7 commented Feb 24, 2023

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
Copy link

I followed those steps but I still get the same error

image

@mrjbq7
Copy link
Collaborator

mrjbq7 commented Feb 24, 2023

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
Copy link

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
Copy link
Collaborator

mrjbq7 commented Feb 25, 2023

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

@mrjbq7
Copy link
Collaborator

mrjbq7 commented Feb 25, 2023

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
Copy link

I have no doubt on that 😅

@42piratas
Copy link

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

@mrjbq7
Copy link
Collaborator

mrjbq7 commented Feb 25, 2023

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

@42piratas
Copy link

Although I was inclined to believe I had a environment issue , now I kind of believe this may not be the case. I have spend the last day reseting entirely my environment. Now I only have one Python version installed in the computer (except for macos' 2.7, ofc) and all packages have been installed from scratch.

$ which python
python: aliased to python3

$ which python3 
/opt/homebrew/bin/python3

$ which pip
pip: aliased to pip3

$ which pip3
/opt/homebrew/bin/pip3

$ which brew
/opt/homebrew/bin/brew

$ 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:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)

$ 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

The error persists, though...

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[2], line 1
----> 1 import talib

File /opt/homebrew/lib/python3.11/site-packages/talib/__init__.py:93
     89 else:
     90     _wrapper = lambda x: x
---> 93 from ._ta_lib import (
     94     _ta_initialize, _ta_shutdown, MA_Type, __ta_version__,
     95     _ta_set_unstable_period as set_unstable_period,
     96     _ta_get_unstable_period as get_unstable_period,
     97     _ta_set_compatibility as set_compatibility,
     98     _ta_get_compatibility as get_compatibility,
     99     __TA_FUNCTION_NAMES__
    100 )
    102 # import all the func and stream functions
    103 from ._ta_lib import *

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
Copy link
Collaborator

mrjbq7 commented Feb 26, 2023

The otool -L line shows that your python C module wasn't built against the libta_lib.0.dylib...

Thats why I asked if running python3 setup.py install worked or had errors, it probably said something about a missing library? I think this would fix it though:

$ export TA_INCLUDE_PATH=/opt/homebrew/opt/ta-lib/include
$ export TA_LIBRARY_PATH=/opt/homebrew/opt/ta-lib/lib
$ python3 -m pip uninstall ta-lib
$ python3 -m pip install ta-lib

This is a pretty terrible experience for you, and I'm sorry. Let's try and get it working for you, then I can try and improve things. The cibuildwheel PR would help since it would make binary wheels and remove the requirement to install and link against ta-lib...

@42piratas
Copy link

42piratas commented Feb 26, 2023

No, it wasn't terrible at all. It's actually been a great opportunity to cleanup my environment and learn a thing or two along the way. And -- the best part -- now it does work indeed!

I really appreciate all your support and patience, and I'm sorry for all the noobie questions. Cheers! 🙌🏽

@Twombles99
Copy link

Sorry for reviving this old topic but I cannot for the life of me synchronise my architectures to all run ARM64. I recently upgraded from an Intel Mac to an M1 Mac and migrated everything over with Migration Assistance, but I guess that carried over all the x86 files and I'm stuck in a weird limbo right now. I was previously using TA-Lib with PyCharm. I tried reinstalling PyCharm for apple silicon, I tried deleting all previous versions of python, I tried deleting all my packages, I even removed my old projects from this device and created a new project and tried running a new venv and fresh pip and brew installs of ta-lib but still get the darn error "symbol not found in flat namespace '_TA_ACOS'"

Any tips on how I can start over?

@mrjbq7
Copy link
Collaborator

mrjbq7 commented Jan 27, 2024 via email

@iKpoxa
Copy link

iKpoxa commented Mar 13, 2024

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

@mrjbq7
Copy link
Collaborator

mrjbq7 commented Mar 13, 2024 via email

@Bytor0
Copy link

Bytor0 commented Jul 11, 2024

Had the same problem and try harded for roundabout 3 hours. In the end i had to install brew for m-chips https://stackoverflow.com/questions/66666134/how-to-install-homebrew-on-m1-mac and uninstall the other brew under /usr/local with the commands
/usr/local/bin/brew list | xargs /usr/local/bin/brew uninstall --force
&
/usr/local/bin/brew install --force /usr/local/bin/brew cleanup --force sudo rm -rf /usr/local/Homebrew sudo rm -rf /usr/local/Caskroom sudo rm -rf /usr/local/Cellar sudo rm -rf /usr/local/var/homebrew sudo rm -rf /usr/local/etc/bash_completion.d sudo rm -rf /usr/local/lib/pkgconfig sudo rm -rf /usr/local/opt sudo rm -rf /usr/local/share/doc/homebrew sudo rm -rf /usr/local/share/man/man1/brew.1 sudo rm -rf /usr/local/share/man/man1/brew-cask.1 sudo rm -rf /usr/local/share/zsh/site-functions/_brew sudo rm -rf /usr/local/share/zsh/site-functions/_brew_cask sudo rm -rf /usr/local/share/zsh/site-functions/_brew_cask sudo rm -rf /usr/local/bin/brew sudo rm -rf /usr/local/bin/brew-cask

after that python3 -m pip install --no-cache-dir ta-lib did it for me

@mrjbq7
Copy link
Collaborator

mrjbq7 commented Jul 11, 2024 via email

@Bytor0
Copy link

Bytor0 commented Jul 11, 2024

Yes I always had 2. But with talib somehow the problems started. One brew is enough brew I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests