skip to Main Content

I want to deploy an app using Heroku but it did not manage to build it. See my build logs under this message.

It looks that my problem is that it cannot load/install Ta-Lib (package that I want to use).

I have 4 documents in my git project:

  1. Procfile

    worker: python StrategyMade.py

  2. 1 file with my python code called StrategyMade.py

  3. config.json (which is settings that I need for the python code)

  4. requirements.txt (all my packages used)

    freqtrade
    pandas
    numpy
    matplotlib

I read online that I need to have buildpacks for Ta-lib so I installed Heroku CLI and then went to terminal and typed the commands in my terminal:

heroku buildpacks:add --index 1 heroku/python -a "name of my project"
heroku buildpacks:add --index 2 numrut/ta-lib -a "name of my project"

and checked if this is added which is true:

screenshot

I ran the app but it gave me some errors. Can someone help me to figure out what is wrong and how I can solve this?Thanks!

Here are my build logs

Building wheel for blosc (PEP 517): finished with status 'done'
         Created wheel for blosc: filename=blosc-1.10.2-cp36-cp36m-linux_x86_64.whl size=2311541 sha256=ceefb8ef23ea2204edd8b3551f2052561c4b9d39d3262c8b0e08b7329f35a7fa
         Stored in directory: /tmp/pip-ephem-wheel-cache-kmy3d35j/wheels/25/ac/11/5268f9b74f868f4c55d3fa63e4e350543d93e4bd1035e66bfd
         Building wheel for TA-Lib (setup.py): started
         Building wheel for TA-Lib (setup.py): finished with status 'error'
         ERROR: Command errored out with exit status 1:
          command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-iwphzu1f/TA-Lib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-iwphzu1f/TA-Lib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-s_lykcmr
              cwd: /tmp/pip-install-iwphzu1f/TA-Lib/
         Complete output (27 lines):
         /tmp/pip-install-iwphzu1f/TA-Lib/setup.py:71: 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_stream.py -> 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/abstract.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_pandas.py -> build/lib.linux-x86_64-3.6/talib
         copying talib/stream.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._ta_lib' 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 -fPIC -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/tmp/pip-install-iwphzu1f/TA-Lib/.eggs/numpy-1.19.5-py3.6-linux-x86_64.egg/numpy/core/include -I/app/.heroku/python/include/python3.6m -c talib/_ta_lib.c -o build/temp.linux-x86_64-3.6/talib/_ta_lib.o
         talib/_ta_lib.c:611:10: fatal error: ta-lib/ta_defs.h: No such file or directory
           611 | #include "ta-lib/ta_defs.h"
               |          ^~~~~~~~~~~~~~~~~~
         compilation terminated.
         error: command 'gcc' failed with exit status 1
         ----------------------------------------
         ERROR: Failed building wheel for TA-Lib
         Running setup.py clean for TA-Lib
         Building wheel for sdnotify (setup.py): started
         Building wheel for sdnotify (setup.py): finished with status 'done'
         Created wheel for sdnotify: filename=sdnotify-0.3.2-py3-none-any.whl size=3212 sha256=1361286b816e23a732caf82e2b98021e5b86ad57082d47b40339832ce585e4fc
         Stored in directory: /tmp/pip-ephem-wheel-cache-kmy3d35j/wheels/ad/c7/fb/b9012fda1d8f9e7749915eab363b35fcd09b3a7f699f2a5ae1
         Building wheel for wrapt (setup.py): started
         Building wheel for wrapt (setup.py): finished with status 'done'
         Created wheel for wrapt: filename=wrapt-1.12.1-cp36-cp36m-linux_x86_64.whl size=75931 sha256=83225a868b63939b67454f0018cf7ba94c4030e0e31ab09b67f5a5b710eec0d4
         Stored in directory: /tmp/pip-ephem-wheel-cache-kmy3d35j/wheels/32/42/7f/23cae9ff6ef66798d00dc5d659088e57dbba01566f6c60db63
         Building wheel for py-find-1st (PEP 517): started
         Building wheel for py-find-1st (PEP 517): finished with status 'done'
         Created wheel for py-find-1st: filename=py_find_1st-1.1.5-cp36-cp36m-linux_x86_64.whl size=36443 sha256=6d269bbd6bc8578f2f937a46c41ab25d8e084b63e170fa02bce30689b5c4642a
         Stored in directory: /tmp/pip-ephem-wheel-cache-kmy3d35j/wheels/90/8d/80/93609354b7435b7f4c3d53407658592cb07bb53e40d9b6015e
         Building wheel for pyrsistent (setup.py): started
         Building wheel for pyrsistent (setup.py): finished with status 'done'
         Created wheel for pyrsistent: filename=pyrsistent-0.17.3-cp36-cp36m-linux_x86_64.whl size=129178 sha256=185ff665281b7f54f0da6d0bb6534cee10f21ce9481ae72fda966e100d1812c5
         Stored in directory: /tmp/pip-ephem-wheel-cache-kmy3d35j/wheels/34/13/19/294da8e11bce7e563afee51251b9fa878185e14f4b5caf00cb
         Building wheel for idna-ssl (setup.py): started
         Building wheel for idna-ssl (setup.py): finished with status 'done'
         Created wheel for idna-ssl: filename=idna_ssl-1.1.0-py3-none-any.whl size=3161 sha256=57671bb402e032f7df82fbd0ed50792447c82e9a5b7a712f6698c63a78833cfa
         Stored in directory: /tmp/pip-ephem-wheel-cache-kmy3d35j/wheels/6a/f5/9c/f8331a854f7a8739cf0e74c13854e4dd7b1af11b04fe1dde13
         Building wheel for typing (setup.py): started
         Building wheel for typing (setup.py): finished with status 'done'
         Created wheel for typing: filename=typing-3.7.4.3-py3-none-any.whl size=26308 sha256=05c526d654cdd48ab5d66e1c8192840c3844d5bce1cbc6cc9da625f772987b43
         Stored in directory: /tmp/pip-ephem-wheel-cache-kmy3d35j/wheels/5f/63/c2/b85489bbea28cb5d36cfe197244f898428004fa3caa7a23116
       Successfully built blosc sdnotify wrapt py-find-1st pyrsistent idna-ssl typing
       Failed to build TA-Lib
       Installing collected packages: tabulate, chardet, urllib3, idna, certifi, requests, wcwidth, prompt-toolkit, questionary, numpy, six, python-dateutil, pytz, pandas, blosc, multidict, yarl, pycparser, cffi, cryptography, idna-ssl, attrs, async-timeout, typing-extensions, aiohttp, pycares, typing, aiodns, ccxt, numexpr, tables, MarkupSafe, jinja2, zipp, importlib-metadata, pyrsistent, jsonschema, cachetools, pycoingecko, TA-Lib, sdnotify, greenlet, SQLAlchemy, python-rapidjson, arrow, wrapt, colorama, py-find-1st, tzlocal, APScheduler, tornado, python-telegram-bot, freqtrade, pillow, kiwisolver, pyparsing, cycler, matplotlib
           Running setup.py install for TA-Lib: started
           Running setup.py install for TA-Lib: finished with status 'error'
           ERROR: Command errored out with exit status 1:
            command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-iwphzu1f/TA-Lib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-iwphzu1f/TA-Lib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-kyza1uz5/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.6m/TA-Lib
                cwd: /tmp/pip-install-iwphzu1f/TA-Lib/
           Complete output (27 lines):
           /tmp/pip-install-iwphzu1f/TA-Lib/setup.py:71: 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_stream.py -> 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/abstract.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_pandas.py -> build/lib.linux-x86_64-3.6/talib
           copying talib/stream.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._ta_lib' 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 -fPIC -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/app/.heroku/python/lib/python3.6/site-packages/numpy/core/include -I/app/.heroku/python/include/python3.6m -c talib/_ta_lib.c -o build/temp.linux-x86_64-3.6/talib/_ta_lib.o
           talib/_ta_lib.c:611:10: fatal error: ta-lib/ta_defs.h: No such file or directory
             611 | #include "ta-lib/ta_defs.h"
                 |          ^~~~~~~~~~~~~~~~~~
           compilation terminated.
           error: command 'gcc' failed with exit status 1
           ----------------------------------------
       ERROR: Command errored out with exit status 1: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-iwphzu1f/TA-Lib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-iwphzu1f/TA-Lib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-kyza1uz5/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.6m/TA-Lib Check the logs for full command output.
 !     Push rejected, failed to compile Python app.
 !     Push failed

2

Answers


  1. TA-Lib is a C library. It has a python wrapper with the same name TA-Lib. The C code must be downloaded and compiled before python wrapper installation. According to your log something tries to install wrapper while C library isn’t installed to the system. But it seems numrut/ta-lib buildpack is aware of this.

    It seems the problem is that freqtrade in your requirements.txt depends on TA-Lib python wrapper. And numrut/ta-lib is trying to install requirements from requirements.txt with pip before it compiles C source and installs TA-Lib wrapper (with pip again). So ta-lib wrapper is trying to be installed twice. And first attempt is made before C sources are compiled which is a fault.

    The possible solution would be to remove freqtrade from requirements.txt and somehow execute pip install -r freqtrade after buildpack numrut/ta-lib is executed. But I don’t know Heroku and not sure how to do this and if this is possible at all. Another options would be: to fork numrut/ta-lib buildpack and make this change it its scriptm then use own fork instead of it. Or to address this issue to numrut/ta-lib author – perhaps he bypass this problem in his script. Or to address this issue to freqtrade authors and ask them to make own buildpack for Heroku.

    Login or Signup to reply.
  2. If your running Ubuntu, you can run

    sudo apt-get update
    sudo apt-get install gcc python3.9
    

    You might not even need python3.9, gcc alone might do it


    If not ubuntu, use yum or whatever your OS uses

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search