Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to install python library in heroku

I am running web apps on heroku. I wanna use TA-Lib. this is library of python. I got error when install it on heroku.

heroku run pip install ta-lib

main, error: command 'gcc' failed with exit status 1.

 Collecting TA-Lib
  Using cached TA-Lib-0.4.10.tar.gz
Building wheels for collected packages: TA-Lib
  Running setup.py bdist_wheel for TA-Lib ... error
  Complete output from command /app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ggrhshl_/TA-Lib/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpy3tq74cipip-wheel- --python-tag cp36:
  /tmp/pip-build-ggrhshl_/TA-Lib/setup.py:77: UserWarning: Cannot find ta-lib library, installation may fail.
    warnings.warn('Cannot find ta-lib library, installation may fail.')
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.6
  creating build/lib.linux-x86_64-3.6/talib
  copying talib/test_func.py -> build/lib.linux-x86_64-3.6/talib
  copying talib/deprecated.py -> build/lib.linux-x86_64-3.6/talib
  copying talib/test_stream.py -> build/lib.linux-x86_64-3.6/talib
  copying talib/test_abstract.py -> build/lib.linux-x86_64-3.6/talib
  copying talib/test_data.py -> build/lib.linux-x86_64-3.6/talib
  copying talib/__init__.py -> build/lib.linux-x86_64-3.6/talib
  running build_ext
  building 'talib.common' extension
  creating build/temp.linux-x86_64-3.6
  creating build/temp.linux-x86_64-3.6/talib
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/app/.heroku/python/lib/python3.6/site-packages/numpy/core/include -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/app/.heroku/python/include/python3.6m -c talib/common.c -o build/temp.linux-x86_64-3.6/talib/common.o
  talib/common.c:242:28: fatal error: ta-lib/ta_defs.h: No such file or directory
   #include "ta-lib/ta_defs.h"
                              ^
  compilation terminated.
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for TA-Lib
  Running setup.py clean for TA-Lib
Failed to build TA-Lib
Installing collected packages: TA-Lib
  Running setup.py install for TA-Lib ... error
    Complete output from command /app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ggrhshl_/TA-Lib/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-7lciel7r-record/install-record.txt --single-version-externally-managed --compile:
    /tmp/pip-build-ggrhshl_/TA-Lib/setup.py:77: UserWarning: Cannot find ta-lib library, installation may fail.
      warnings.warn('Cannot find ta-lib library, installation may fail.')
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/talib
    copying talib/test_func.py -> build/lib.linux-x86_64-3.6/talib
    copying talib/deprecated.py -> build/lib.linux-x86_64-3.6/talib
    copying talib/test_stream.py -> build/lib.linux-x86_64-3.6/talib
    copying talib/test_abstract.py -> build/lib.linux-x86_64-3.6/talib
    copying talib/test_data.py -> build/lib.linux-x86_64-3.6/talib
    copying talib/__init__.py -> build/lib.linux-x86_64-3.6/talib
    running build_ext
    building 'talib.common' extension
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/talib
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/app/.heroku/python/lib/python3.6/site-packages/numpy/core/include -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/app/.heroku/python/include/python3.6m -c talib/common.c -o build/temp.linux-x86_64-3.6/talib/common.o
    talib/common.c:242:28: fatal error: ta-lib/ta_defs.h: No such file or directory
     #include "ta-lib/ta_defs.h"
                                ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ggrhshl_/TA-Lib/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-7lciel7r-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-ggrhshl_/TA-Lib/

I have avoid when I installed ta-lib in my ubuntu.

sudo apt-get install python3-dev

Problem is what sudo command can't use on heroku. so I don't know what I have to do. how to install ta-lib in heroku ??

like image 607
taka Avatar asked Nov 29 '25 06:11

taka


1 Answers

Add this one to your app's buildpack list: https://github.com/numrut/heroku-buildpack-python-talib

It should be placed after heroku/python.

And remove TA-Lib from your requirements.txt if it is already there.

like image 96
numrut Avatar answered Nov 30 '25 22:11

numrut