在 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
希望这也能节省其他人的时间。
在 Ubuntu 22.04 中,我按照以下步骤解决了这个问题;
(顺便说一句,官方页面也提到了这里)
cd ~/talib
和;tar -xzf ta-lib-0.4.0-src.tar.gz
cd ta-lib/
./configure --prefix=/usr
make
sudo make install
编辑主目录中的 .bashrc 并添加以下行: 请记住将 PREFIX 更改为您的 talib 路径 (~/talib/ta-lib/)
导出 TA_LIBRARY_PATH=$PREFIX/lib
导出 TA_INCLUDE_PATH=$PREFIX/include
pip install TA-Lib
然后就安装成功了。 祝你好运!
在 mac 终端上执行时已解决:
$ brew install ta-lib
出现此错误是因为 TA-Lib 的 Wheel 文件与您的系统不兼容。 Wheel 文件是库的预构建版本,特定于特定版本的 Python 和特定操作系统架构(例如 Windows、Linux、macOS)。
您可以尝试采取以下几种方法来解决此错误:
确保您的系统上安装了正确版本的 Python。您尝试安装的 TA-Lib 轮文件适用于 Python 3.10,因此您需要安装该版本的 Python 才能使用它。
检查您尝试安装的wheel文件是否适用于正确的架构(例如,适用于Windows 64位的win_amd64)。
您可以尝试从源代码构建轮子。您可以尝试从 TA-Lib 网站下载源代码,然后尝试从源代码构建它。它将确保您拥有该版本的Python和操作系统架构的wheel文件。
或者,您可以尝试使用 pip 安装库,而不使用 Wheel 文件,方法是使用命令:pip install TA-Lib
或者您可以寻找与您的系统架构和Python版本相匹配的TA-Lib的另一个wheel文件。
通过尝试上述任何解决方案,您应该能够成功安装 TA-Lib 库。
解决方案是安装正确的版本:
cp310 表示 CPython 3.10(Cpython 是我们从 python.org 安装的基本 Python)。
win_amd64 表示可以安装在64位系统中
cp39表示可以安装在CPython 3.9上
等等...
检查安装正确的版本。这对我有用。
您的系统需要正确的编译器来构建
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
!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
祝你好运!
% 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
ta-lib/ta_defs.h: No such file or directory
,我只是使用了
python3 -m pip install TA-Lib-Precompiled
,这对我有用。