[Python] Cannot load databricks in my container because of numpy import error

Discussão em 'Python' iniciado por Stack, Abril 29, 2025.

  1. Stack

    Stack Membro Participativo

    I have a fairly simple Docker file to deploy on Lambda

    FROM public.ecr.aws/lambda/python:3.9

    COPY requirements.txt .
    RUN pip install -r requirements.txt --target "${LAMBDA_TASK_ROOT}"

    COPY lambda_function.py ${LAMBDA_TASK_ROOT}
    CMD [ "lambda_function.lambda_handler" ]


    My requirements

    ~/lambda_databricks_docker$ cat requirements.txt
    databricks-sql-connector
    numpy
    pandas


    In my python script I import these

    import json
    import csv
    import io
    import requests
    import os # <-- Used for environment variables
    from databricks import SQL


    And this is the error:

    {"error": "Databricks connection failed: Unable to import required dependencies:\nnumpy: Error importing numpy: you should not try to import numpy from\n its source directory; please exit the numpy source tree, and relaunch\n your python interpreter from there."}


    I've been trying to solve this with 3 different AI's and the web...no luck

    Continue reading...

Compartilhe esta Página