如何在heroku中安装python库

时间:2017-04-17 15:00:18

标签: python-3.x heroku

我在heroku上运行网络应用程序。 我想使用TA-Lib。这是python库。 我在heroku上安装时遇到错误。

heroku run pip install ta-lib

main,错误:命令'gcc'因退出状态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/

在我的ubuntu中安装ta-lib时,我已经避免了。

sudo apt-get install python3-dev

问题是sudo命令无法在heroku上使用。 所以我不知道自己要做什么。 如何在heroku中安装ta-lib?

1 个答案:

答案 0 :(得分:2)

将此问题添加到您应用的构建包列表中:https://github.com/numrut/heroku-buildpack-python-talib

应放在heroku/python之后。

如果TA-Lib已经存在,请从requirements.txt中删除。{/ p>