我正在使用 Heroku 部署 Django 应用程序。我的应用程序的依赖项之一是“ta-lib”库,它是用 C 编写的库的 Python 包装器。为了让它在本地工作,我只需要下载底层的 C 库,程序就会选择它从 /usr/local 需要,我没有问题。
库参考:https://mrjbq7.github.io/ta-lib/install.html
现在,当我尝试通过 Git 将文件推送到 Heroku 时,此库的构建失败。这是终端输出,从错误开始的地方开始:
remote: Building wheel for TA-Lib (setup.py): started
remote: Building wheel for TA-Lib (setup.py): finished with status 'error'
remote: ERROR: Command errored out with exit status 1:
remote: command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ya1rkeoc/ta-lib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ya1rkeoc/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/pip-wheel-e83ejfm_
remote: cwd: /tmp/pip-install-ya1rkeoc/ta-lib/
remote: Complete output (27 lines):
remote: /tmp/pip-install-ya1rkeoc/ta-lib/setup.py:71: UserWarning: Cannot find ta-lib library, installation may fail.
remote: warnings.warn('Cannot find ta-lib library, installation may fail.')
remote: running bdist_wheel
remote: running build
remote: running build_py
remote: creating build
remote: creating build/lib.linux-x86_64-3.9
remote: creating build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_data.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_func.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/stream.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/__init__.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_abstract.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/abstract.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/deprecated.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_pandas.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_stream.py -> build/lib.linux-x86_64-3.9/talib
remote: running build_ext
remote: building 'talib._ta_lib' extension
remote: creating build/temp.linux-x86_64-3.9
remote: creating build/temp.linux-x86_64-3.9/talib
remote: 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-ya1rkeoc/ta-lib/.eggs/numpy-1.20.3-py3.9-linux-x86_64.egg/numpy/core/include -I/app/.heroku/python/include/python3.9 -c talib/_ta_lib.c -o build/temp.linux-x86_64-3.9/talib/_ta_lib.o
remote: talib/_ta_lib.c:611:10: fatal error: ta-lib/ta_defs.h: No such file or directory
remote: 611 | #include "ta-lib/ta_defs.h"
remote: | ^~~~~~~~~~~~~~~~~~
remote: compilation terminated.
remote: error: command '/usr/bin/gcc' failed with exit code 1
remote: ----------------------------------------
remote: ERROR: Failed building wheel for TA-Lib
remote: Running setup.py clean for TA-Lib
remote: Building wheel for wrapt (setup.py): started
remote: Building wheel for wrapt (setup.py): finished with status 'done'
remote: Created wheel for wrapt: filename=wrapt-1.12.1-cp39-cp39-linux_x86_64.whl size=78588 sha256=bcbc0270be5d84ca062d30a118d3e1b5bb48b1eb96ca15d72db3ba00e95e33dc
remote: Stored in directory: /tmp/pip-ephem-wheel-cache-xcx232so/wheels/98/23/68/efe259aaca055e93b08e74fbe512819c69a2155c11ba3c0f10
remote: Successfully built lazy-object-proxy wrapt
remote: Failed to build TA-Lib
remote: Installing collected packages: asgiref, six, wrapt, lazy-object-proxy, astroid, certifi, chardet, Cython, pytz, sqlparse, Django, gunicorn, idna, isort, mccabe, numpy, urllib3, requests, pycoingecko, toml, pylint, TA-Lib, typed-ast
remote: Running setup.py install for TA-Lib: started
remote: Running setup.py install for TA-Lib: finished with status 'error'
remote: ERROR: Command errored out with exit status 1:
remote: command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ya1rkeoc/ta-lib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ya1rkeoc/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-record-l9p7ava0/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.9/TA-Lib
remote: cwd: /tmp/pip-install-ya1rkeoc/ta-lib/
remote: Complete output (28 lines):
remote: /tmp/pip-install-ya1rkeoc/ta-lib/setup.py:71: UserWarning: Cannot find ta-lib library, installation may fail.
remote: warnings.warn('Cannot find ta-lib library, installation may fail.')
remote: running install
remote: running build
remote: running build_py
remote: creating build
remote: creating build/lib.linux-x86_64-3.9
remote: creating build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_data.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_func.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/stream.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/__init__.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_abstract.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/abstract.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/deprecated.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_pandas.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_stream.py -> build/lib.linux-x86_64-3.9/talib
remote: running build_ext
remote: skipping 'talib/_ta_lib.c' Cython extension (up-to-date)
remote: building 'talib._ta_lib' extension
remote: creating build/temp.linux-x86_64-3.9
remote: creating build/temp.linux-x86_64-3.9/talib
remote: 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.9/site-packages/numpy/core/include -I/app/.heroku/python/include/python3.9 -c talib/_ta_lib.c -o build/temp.linux-x86_64-3.9/talib/_ta_lib.o
remote: talib/_ta_lib.c:611:10: fatal error: ta-lib/ta_defs.h: No such file or directory
remote: 611 | #include "ta-lib/ta_defs.h"
remote: | ^~~~~~~~~~~~~~~~~~
remote: compilation terminated.
remote: error: command '/usr/bin/gcc' failed with exit code 1
remote: ----------------------------------------
remote: 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-ya1rkeoc/ta-lib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ya1rkeoc/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-record-l9p7ava0/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.9/TA-Lib Check the logs for full command output.
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to <my-app-name>.
remote:
To https://git.heroku.com/<my-app-name>.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/<my-app-name>.git'enter code here
如何确定需要底层 C 库中的哪些文件,以及在推送代码时将它们添加到 Django 项目的何处?
谢谢。