无法使用Macbook Pro M1芯片macOS Big Sur版本11.4导入TA-lib

问题描述 投票:0回答:2

我已经使用以下命令成功安装了

TA-Lib

brew install ta-lib
pip3 install ta-lib

之后,命令

pip3 list
已显示
TA-Lib
版本。

TA-Lib             0.4.21

但是,当我尝试

import talib
时,出现了错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/talib/__init__.py", line 52, in <module>
    from ._ta_lib import (
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/talib/_ta_lib.cpython-39-darwin.so, 2): Symbol not found: _TA_ACOS
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/talib/_ta_lib.cpython-39-darwin.so
  Expected in: flat namespace in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/talib/_ta_lib.cpython-39-darwin.so

您能建议如何解决这个问题吗?

python macos visual-studio-code ta-lib
2个回答
0
投票

我也遇到了同样的问题,我解决了。 系统是MacOS M1 |蟒蛇3.9 我尝试了

brew install 
,但
pip install
不起作用,talib无法导入。


所以,我的解决方案是尝试使用[anaconda]

  1. 选择下载anaconda MacOS M1:https://www.anaconda.com/download
  2. 安装应用程序 [anaconda] 并创建环境
  3. 使用[PyCharm],
  4. 选择添加Python解释器
  5. 选择康达环境
  6. 启用[确定]按钮
  7. 编码...并完成

0
投票

遇到同样的问题,努力绕了3个小时。几乎尝试了论坛中你能找到的每一个动作..最后我不得不为 m-chips 安装brew 如何在 M1 mac 上安装 homebrew 并使用命令卸载 /usr/local 下的其他brew

/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

之后

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

为我做的

© www.soinside.com 2019 - 2024. All rights reserved.