1

Here is the error that I'm getting when I try to install Ta-Lib in Cloud Run using a Dockerfile

 error: subprocess-exited-with-error
  
  × Building wheel for ta-lib (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [27 lines of output]
      <string>:77: UserWarning: Cannot find ta-lib library, installation may fail.
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-310
      creating build/lib.linux-x86_64-cpython-310/talib
      copying talib/test_polars.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/test_pandas.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/__init__.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/test_stream.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/stream.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/abstract.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/deprecated.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/test_func.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/test_abstract.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/test_data.py -> build/lib.linux-x86_64-cpython-310/talib
      running build_ext
      building 'talib._ta_lib' extension
      creating build/temp.linux-x86_64-cpython-310
      creating build/temp.linux-x86_64-cpython-310/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/opt/homebrew/include -I/opt/homebrew/opt/ta-lib/include -I/tmp/pip-build-env-yj8q5fu_/normal/lib/python3.10/site-packages/numpy/core/include -I/usr/local/include/python3.10 -c talib/_ta_lib.c -o build/temp.linux-x86_64-cpython-310/talib/_ta_lib.o
      talib/_ta_lib.c:747:10: fatal error: ta-lib/ta_defs.h: No such file or directory
        747 | #include "ta-lib/ta_defs.h"
            |          ^~~~~~~~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for ta-lib
Successfully built websocket
Failed to build ta-lib
ERROR: Could not build wheels for ta-lib, which is required to install pyproject.toml-based projects

[notice] A new release of pip available: 22.2.2 -> 22.3.1
[notice] To update, run: pip install --upgrade pip
The command '/bin/sh -c pip install --no-cache-dir -r requirements.txt' returned a non-zero code: 1
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

BUILD FAILURE: Build step failure: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1
ERROR: (gcloud.builds.submit) build 8c54cd65-f189-476a-8bd9-f7fe7b428bfe completed with status "FAILURE"

My requirements.txt file looks like this:

Flask==2.1.0
gunicorn==20.1.0
websocket
pandas
numpy
ta-lib

And my Dockerfile looks like this:

FROM python:3.10-slim

ENV PYTHONUNBUFFERED True

# Copy local code to the container image.
WORKDIR /var/www/html
COPY . /var/www/html/

# Install production dependencies.
RUN pip install --no-cache-dir -r requirements.txt

CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 main:app

Has anyone been able to install Python package Ta-Lib using Dockerfile? I've been breaking my head over the wall to make it work but it won't.

Steeve
  • 385
  • 2
  • 13

1 Answers1

1

I found a solution to solve the issue / error from a post on csdn website, as follows:

To solve the issue, one needs to first install the extension library for LA-Lib, then use pip to install the package.

MacOS X, run the following command:

Make sure that you have write permission (i.e., admin account)to the target folder: /usr/local/Cellar

$ brew install ta-lib

==> Pouring ta-lib--0.4.0.monterey.bottle.1.tar.gz

/usr/local/Cellar/ta-lib/0.4.0: 14 files, 2.4MB

==> Running brew cleanup ta-lib...

$ pip install ta-lib

Collecting ta-lib

Using cached TA-Lib-0.4.25.tar.gz (271 kB)

Installing build dependencies ... done

Getting requirements to build wheel ... done

Installing backend dependencies ... |^@^done

Successfully installed ta-lib-0.4.25

For Windows:

Download ta-lib-0.4.0-msvc.zip from the following url, then uncompress to directory: C:\ta-lib

        https://sourceforge.net/projects/ta-lib/files/ta-lib/0.4.0/ta-lib-0.4.0-msvc.zip/download?use_mirror=jaist

change to the target folder and run the install command.

If Windows complain with the new error infor: Unable to find vcvarsall.bat. You should go to the website, https://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib, to download the correct version of ta-lib for your Windows version.

Then run the following command to install.

pip install TA_Lib‑0.4.17‑cp35‑cp35m‑win_amd64.whl
Good Will
  • 1,220
  • 16
  • 10