我在 pip 安装 ta-lib 时遇到错误。 我使用命令:
!pip install ta-lib
请给我解决方案
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Collecting ta-lib
Using cached TA-Lib-0.4.25.tar.gz (271 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy in /usr/local/lib/python3.8/dist-packages (from ta-lib) (1.21.6)
Building wheels for collected packages: ta-lib
error: subprocess-exited-with-error
× Building wheel for ta-lib (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
Building wheel for ta-lib (pyproject.toml) ... error
ERROR: Failed building wheel for ta-lib
Failed to build ta-lib
ERROR: Could not build wheels for ta-lib, which is required to install pyproject.toml-based projects
我尝试了以下命令:
pip install --upgrade pip setuptools wheel
pip install pep517
!pip3 install --upgrade pip
!pip install pyproject-toml
pip install TA_Lib‑0.4.10‑cp35‑cp35m‑win_amd64.whl
!pip install ta-lib
在 Anaconda 命令提示符中键入以下命令(完全像这样)为我修复了它:
conda install -c conda-forge ta-lib
希望这也能节省其他人的时间。
出现此错误是因为 TA-Lib 的 wheel 文件与您的系统不兼容。 wheel 文件是特定于特定版本的 Python 和特定操作系统架构(例如,Windows、Linux、macOS)的库的预构建版本。
您可以尝试一些方法来解决此错误:
确保您的系统上安装了正确版本的 Python。您尝试安装的 TA-Lib wheel 文件适用于 Python 3.10,因此您需要安装该版本的 Python 才能使用它。
检查您尝试安装的 wheel 文件是否适用于正确的架构(例如,win_amd64 适用于 Windows 64 位)。
你可以尝试从源码造轮子。您可以尝试从 TA-Lib 网站下载源代码,然后尝试从源代码构建它。它将确保您将拥有该版本的 python 和操作系统架构的 wheel 文件。
或者,您可以尝试使用 pip 安装库,而不使用 wheel 文件,方法是使用命令:pip install TA-Lib
或者您可以寻找另一个与您的系统架构和 Python 版本匹配的 TA-Lib 的 wheel 文件。
通过尝试上述任何解决方案,您应该能够成功安装 TA-Lib 库。
在 Ubuntu 22.04 中,我按照以下步骤解决了这个问题;
(顺便说一句,官方页面中也提到了here)
cd ~/talib
和;tar -xzf ta-lib-0.4.0-src.tar.gz
cd ta-lib/
./configure --prefix=/usr
make
sudo make install
在您的主目录中编辑 .bashrc 并添加以下行: 请记住用您的 talib 路径更改PREFIX (~/talib/ta-lib/)
导出 TA_LIBRARY_PATH=$PREFIX/lib
导出 TA_INCLUDE_PATH=$PREFIX/include
pip install TA-Lib
然后就安装成功了。 祝你好运!
解决方法是安装正确的版本:
cp310 表示 CPython 3.10(Cpython 是我们从 python.org 安装的基本 Python)。
win_amd64 表示可以安装在 64 位系统中
cp39 表示可以在 CPython 3.9 上安装
等等...
检查以安装正确的版本。它对我有用。
有两种方法,先试试下面的方法,它在 Google Colab 上有效:
!curl -L http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz -O && tar xzvf ta-lib-0.4.0-src.tar .gz !cd ta-lib && ./configure --prefix=/usr && make && make install && cd - && pip install ta-lib
祝你好运!
我试过了 - 但失败并出现以下错误,有什么建议吗?
!curl -L http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz -O && tar xzvf ta-lib-0.4.0-src.tar.gz !cd ta-lib && ./configure --prefix=/usr && make && make install && cd - && pip install ta-lib
ta-lib/src/tools/ta_regtest/ta_gDataLow.c
ta-lib/src/tools/Makefile.in
ta-lib/src/tools/Makefile.am
"ta-lib/src/tools/gen_code/
ta-lib/src/tools/gen_code/java/
ta-lib/src/tools/gen_code/java/PrettyCode.java
ta-lib/src/tools/gen_code/java/Main.java
ta-lib/src/tools/gen_code/gen_code.c
ta-lib/src/tools/gen_code/Makefile.in
ta-lib/src/tools/gen_code/Makefile.am
ta-lib/src/tools/gen_code/mcpp.exe
tar: !cd: Not found in archive
tar: Exiting with failure status due to previous errors"
> Blockquote
我在 Mac Big Sur 上遇到问题,直到我重新安装命令行工具并更新了 clang ...
% sudo rm -rf /Library/Developer/CommandLineTools
% sudo xcode-select --install
% clang --version
Apple clang version 12.0.5 (clang-1205.0.22.11)
THEN...
$ pip3 install ta-lib
Collecting ta-lib
Using cached TA-Lib-0.4.25.tar.gz (271 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy in /usr/local/lib/python3.10/site-packages (from ta-lib) (1.24.0)
Building wheels for collected packages: ta-lib
Building wheel for ta-lib (pyproject.toml) ... done
Created wheel for ta-lib: filename=TA_Lib-0.4.25-cp310-cp310-macosx_11_0_x86_64.whl size=450718 sha256=d793bcd939d8b4c43efa00359ae45207e18d5d622a3d794f8da1fef12279d23b
Stored in directory: /Users/xxxxxx/Library/Caches/pip/wheels/ac/12/d0/2ea05cfb5b9c4bbf47b45dd93ff5baed86ddb85c748166cb6f
Successfully built ta-lib
Installing collected packages: ta-lib
Successfully installed ta-lib-0.4.25
解决了在终端上执行的mac:
$ brew install ta-lib
它需要正确的编译器与您的系统来构建
ta-lib
python包,因为pip install
从不安装编译器.
gtar
时遇到了类似的问题。我只包含类似的错误消息。
[..]
Building wheels for collected packages: gtar
Building wheel for gtar (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for gtar (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [15 lines of output]
[..]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for gtar
Failed to build gtar
ERROR: Could not build wheels for gtar, which is required to install pyproject.toml-based projects
按照建议安装 Microsoft Visual C++ 14.0 或更高版本后,在我的例子中是使用 Visual Studio Build Tools 2022 -- 17.4.5 使用 C++(包括 MVSC v143)进行桌面开发,它成功构建如下。
[..
Building wheels for collected packages: gtar
Building wheel for gtar (pyproject.toml) ... done
Created wheel for gtar: filename=gtar-1.1.3-cp310-cp310-win_amd64.whl size=618949 sha256=3179a7e8b5deb7e72f5722acc08fbecdfec6eeab88c4ac5778d3287a45635086
Stored in directory: c:\users\full name\appdata\local\pip\cache\wheels\8a\10\b1\eddc3353608cbc386b0113f2bea34c83e5fae7ce26deb059db
Successfully built gtar
Installing collected packages: gtar
Successfully installed gtar-1.1.3