Menu

#108 Issues building Docker Image

open
nobody
5
2021-01-25
2021-01-25
kas nawaz
No

Hello,
I'm trying to build a Docker image with talib - which does build.
But when I run it, I see:

Exception has occurred: ModuleNotFoundError
No module named 'talib'
File "C:\Users\Kasar\source\temp\test.py", line 12, in <module>
import talib</module>

My Dockerfile is standard boiler plate
- except section 'Setup Talib' (which I borrowed from a forum)

#Dockerfile

FROM python:3.8

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
COPY requirements.txt .
RUN python -m pip install -r requirements.txt

# Setup TA-Lib
RUN wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz && \
tar -xzf ta-lib-0.4.0-src.tar.gz && \
cd ta-lib/ && \
./configure --prefix=/usr && \
make && \
make install

WORKDIR /app
COPY . /app

RUN useradd appuser && chown -R appuser /app
USER appuser

CMD ["python", "test.py"]

Can anyone help debug what's going wrong please,
Thank you

Discussion

  • kas nawaz

    kas nawaz - 2021-01-25

    Digging deeper into the build inside the config.log, I see:

    configure: failed program was:
    | / confdefs.h. /
    | #define PACKAGE_NAME "ta-lib"
    | #define PACKAGE_TARNAME "ta-lib"
    | #define PACKAGE_VERSION "0.4.0"
    | #define PACKAGE_STRING "ta-lib 0.4.0"
    | #define PACKAGE_BUGREPORT "http://sourceforge.net/tracker/?group_id=8903&atid=108903"
    | #define PACKAGE "ta-lib"
    | #define VERSION "0.4.0"

    and

    configure:20612: checking for pow
    configure:20668: gcc -o conftest -g -O2 conftest.c -lpthread -ldl >&5
    conftest.c:69:6: warning: conflicting types for built-in function 'pow' [-Wbuiltin-declaration-mismatch]
    char pow ();
    ^~~
    /usr/bin/ld: /tmp/cctOKw0g.o: in function main': /ta-lib/conftest.c:80: undefined reference topow'
    collect2: error: ld returned 1 exit status

    Does that help ?

    Thank you

     
  • Alexander Trufanov

    ta-lib is a library written in C. It's not a python module and can't be loaded into python directly. You need a python wrapper around ta-lib. By "import talib" you are trying to find and load such wrapper. The python wrapper is another project and hosted here: https://github.com/mrjbq7/ta-lib
    It could be build on machine or installed with help of "pip install ta-lib". So you should have both - c library and python wrapper for it on machine.

     
    👍
    1

Log in to post a comment.