问题
I am getting gcc error when trying to install Ta-lib as a global package on my mac.
I get an error below:
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
I am not sure I understand what this means? pip install Ta-lib package is missing a file? It would make sense but it installs fine for my Ubuntu server, just having issues with my mac. Ubuntu is also running Python with Anaconda with same version.
My gcc version below:
➜ ~ 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
My Python installation information below:
➜ ~ which python
/anaconda/bin/python
➜ ~ python --version
Python 3.6.1 :: Anaconda custom (x86_64)
I would actually prefer Ta-lib installed as global conda package as I end up using it with most of my notebooks that are pretty ad-hoc work.
回答1:
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
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.
回答2:
1) Install ta-lib
using brew.
brew install ta-lib
2) Then Ran the pip install TA-Lib
command.
The above step should work in most of the cases, but one of my friend was facing some issue with gcc
, if you are facing any issue related to gcc
, try installing gcc
. For installing gcc
you can use the command: brew install gcc
Hope this helps.
回答3:
I had a lot of problems with this one as well. I'm adding my answer here as none of the answers I'd read gave me this approach which was the solution for me and will be for those whose "homebrew" does not install in a directory the ta-lib setup is looking for.
I had installed the "underlying" ta-lib previously with brew install ta-lib
, but it was still giving the same error. I downloaded the ta-lib python project with git clone https://github.com/mrjbq7/ta-lib.git
so I could examine and change the routes where it was looking for my "underlying" ta-lib which it wasn't finding. In setup.py
you can see the directories in which it is looking for the ta-lib that brew installed. But mine wasn't in any of the directories mentioned there.
I found where brew had installed ta-lib by running brew --prefix ta-lib
. This gave me the base directory. Then I could add the corresponding include and lib directories to the directory lists. I then ran python setup.py install
from the ta-lib project I downloaded from github and it worked!
To be more precise: running brew --prefix ta-lib
gave me something like /Users/myuser/homebrew/opt/ta-lib
. In the file setup.py
around the line 25, there is a variable called include_dirs
which is set to a list of directories. To that variable I added my location for the include directory, that is /Users/myuser/homebrew/opt/ta-lib/include
. Around line 36 in the same file, there is another variable, lib_talib_dirs
, and to that variable I also added my location for the lib directory, that is /Users/myuser/homebrew/opt/ta-lib/lib
. Then I ran python setup.py install
etc.
回答4:
I had a similar and a bunch of other TA-Lib installation issues( MAC OS).
It appears that except that you need to process installation from github or from PIP it should be already installed before that on the machine( or sort of... )
What helped with that -->
uninstall homebrew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
and then install it again:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
After that run brew install ta-lib
And then change directory to the one with TA-Lib setup.py
and proceed with command python setup.py install
... should work
回答5:
I use mac Catalina with python3.8 and was working in virtualenv. I tried all the suggestions on this page and others with no luck for a couple of days, at one point I thought that the difference between the brew TA-lib version(0.4.0) and pip ta-lib version(0.4.19) was the issue so tried to install version 0.4.19 with brew and vise versa with no luck. Finally I gave up and moved to pandas-ta.
Next day I started having the very similar error message with Twisted and while researching that issue I learned that it doesnt support beyond python3.7 so I created a conda environment and its installation was a breeze. Tried the same thing with TA-Lib, python3.7 conda environment, brew install ta-lib then pip install TA-Lib and voila, TA-Lib-0.4.19 was installed.
I hope this would help anyone with similar circumstances.
来源:https://stackoverflow.com/questions/43270089/installing-ta-lib-creates-gcc-error