安装Ta-lib会导致gcc错误

时间:2017-04-07 05:08:01

标签: python python-3.x gcc ta-lib

尝试在我的Mac上安装Ta-lib作为全局程序包时出现gcc错误。

我在下面收到错误:

   gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I//anaconda/include -arch x86_64 -I//anaconda/include -arch x86_64 -I//anaconda/lib/python3.6/site-packages/numpy/core/include -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I//anaconda/include/python3.6m -c talib/common.c -o build/temp.macosx-10.7-x86_64-3.6/talib/common.o
    talib/common.c:242:10: fatal error: 'ta-lib/ta_defs.h' file not found
    #include "ta-lib/ta_defs.h"
             ^
    1 error generated.
    error: command 'gcc' failed with exit status 1

我不确定我明白这意味着什么? pip install Ta-lib包丢失了一个文件?它会有意义,但它安装好我的Ubuntu服务器,只是我的Mac有问题。 Ubuntu也使用相同版本的Anaconda运行Python。

我的gcc版本如下:

➜  ~ which gcc
/usr/bin/gcc
➜  ~ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

我的Python安装信息如下:

➜  ~ which python
/anaconda/bin/python
➜  ~ python --version
Python 3.6.1 :: Anaconda custom (x86_64)

我实际上更喜欢安装Ta-lib作为全球conda包,因为我最终使用它与我的大多数笔记本电脑非常特别的工作。

5 个答案:

答案 0 :(得分:7)

Yesterday it took me much time to solve the problem but I still couldn't make it. Just now I succeeded to install TA-Lib! Below is the solution.

First I run 'brew install ta-lib' in the Mac terminal. Then I open the PyCharm, file->default settings->project interpreter->choose python 3.6(my python version)->'+' and input 'TA-Lib' -> install->FINISH!

Before I solve the problem, I have a look at the TA-Lib folder downloaded from the Internet. It's said in the README.md that

"Sometimes installation will produce build errors like this:

func.c:256:28: fatal error: ta-lib/ta_libc.h: No such file or directory compilation terminated.

This typically means that it can't find the underlying TA-Lib library, a dependency which needs to be installed."

and then I find

"### Dependencies

To use TA-Lib for python, you need to have the TA-Lib already installed:

Mac OS X

$ brew install ta-lib

Windows

Download ta-lib-0.4.0-msvc.zip and unzip to C:\ta-lib " Therefore the problem is solved. I hope this will help you.

答案 1 :(得分:1)

1)使用brew安装ta-lib

brew install ta-lib

2)然后运行pip install TA-Lib命令。

在大多数情况下,上述步骤应该有效,但是我的一位朋友遇到了gcc的问题,如果您遇到与gcc相关的任何问题,请尝试安装{{1} }。要安装gcc,可以使用以下命令:
gcc

希望这会有所帮助。

答案 2 :(得分:1)

我也遇到了很多问题。我在这里添加我的答案,因为我读过的所有答案都没有给我这种方法,这对我来说是解决方案,并且适用于那些“自制软件”没有安装在 ta-lib 安装程序正在寻找的目录中的人。

我之前使用 brew install ta-lib 安装了“基础”ta-lib,但它仍然给出相同的错误。我使用 git clone https://github.com/mrjbq7/ta-lib.git 下载了 ta-lib python 项目,因此我可以检查和更改它正在寻找它没有找到的“基础”ta-lib 的路线。在 setup.py 中,您可以看到它正在寻找 brew 安装的 ta-lib 的目录。但我的不在那里提到的任何目录中。 我通过运行 brew --prefix ta-lib 找到了 brew 安装 ta-lib 的位置。这给了我基本目录。然后我可以将相应的 include 和 lib 目录添加到目录列表中。然后我从我从 github 下载的 ta-lib 项目中运行 python setup.py install 并且它工作了!

更准确地说:运行 brew --prefix ta-lib 给了我类似 /Users/myuser/homebrew/opt/ta-lib 的结果。在文件 setup.py 的第 25 行附近,有一个名为 include_dirs 的变量,它被设置为目录列表。我向该变量添加了包含目录的位置,即 /Users/myuser/homebrew/opt/ta-lib/include。在同一个文件的第 36 行附近,还有另一个变量 lib_talib_dirs,我还在该变量中添加了 lib 目录的位置,即 /Users/myuser/homebrew/opt/ta-lib/lib。然后我跑了 python setup.py install

答案 3 :(得分:0)

我遇到了类似的问题以及其他许多TA-Lib安装问题(MAC OS)。

看来,除了您需要从github或PIP处理安装之外,它应该已经安装在机器上(或类似...)

什么帮助了->

卸载自制软件:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

然后重新安装:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

此后运行brew install ta-lib 然后使用TA-Lib setup.py将目录更改为该目录,并继续执行命令python setup.py install ...应该工作

答案 4 :(得分:0)

我使用带有 python3.8 的 mac Catalina 并且在 virtualenv 中工作。我尝试了此页面上的所有建议和其他人几天都没有运气,一度我认为 brew TA-lib 版本(0.4.0)和 pip ta-lib 版本(0.4.19)之间的区别是这个问题,所以尝试用 brew 安装 0.4.19 版本,反之亦然,但没有运气。最后我放弃了,转而使用 pandas-ta。

第二天,我开始收到与 Twisted 非常相似的错误消息,在研究该问题时,我了解到它不支持 python3.7 以外的版本,因此我创建了一个 conda 环境,并且它的安装轻而易举。在 TA-Lib、python3.7 conda 环境中尝试了同样的事情,brew install ta-lib 然后 pip install TA-Lib 和 voila,安装了 TA-Lib-0.4.19。

我希望这能帮助任何有类似情况的人。

相关问题