im having problems with download-files on dockerfi...
# ask-ai
e
im having problems with download-files on dockerfile: ImportError: cannot import name 'LogData' from 'opentelemetry.sdk._logs' (/home/appuser/.local/lib/python3.11/site-packages/opentelemetry/sdk/_logs/__init__.py)
t
Thanks for reaching out, Miguel. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're seeing a version-compatibility error:
LogData
was removed from
opentelemetry.sdk._logs
in OpenTelemetry Python SDK v1.20.0, so code or a dependency expecting
LogData
fails to import. Two simple fixes — pick one that fits your project: • Pin the OpenTelemetry SDK to a version that still provides
LogData
(quickest fix): a. In your Dockerfile or requirements, install a compatible SDK, for example:
Copy code
RUN pip install "opentelemetry-sdk<1.20.0"
1. Rebuild the image. • Update code/dependencies to the newer API (longer-term fix): a. Replace imports of
LogData
with
LogRecord
and update any log-related code to the new API:
Copy code
from opentelemetry.sdk._logs import LogRecord
1. Ensure any third-party packages (e.g.,
livekit-agents
) you use are compatible with OpenTelemetry ≥1.20.0 or upgrade them if newer releases support the new logging API. If you want, tell me: • which packages/versions you install in your Dockerfile (your
pip install
line or requirements.txt), and • whether you prefer pinning or updating code — I’ll give the exact Dockerfile changes or the code refactor steps. Sources: How to Send Logs from the JavaScript SDK to Providers like Datadog | Observability data hooks | LiveKit docs
e
3.263 File "<frozen runpy>", line 198, in _run_module_as_main 3.263 File "<frozen runpy>", line 88, in _run_code 3.263 File "/home/appuser/agent/main.py", line 16, in <module> 3.263 from livekit.agents import ( 3.263 File "/home/appuser/.local/lib/python3.11/site-packages/livekit/agents/__init__.py", line 23, in <module> 3.263 from . import cli, inference, ipc, llm, metrics, stt, tokenize, tts, utils, vad, voice 3.263 File "/home/appuser/.local/lib/python3.11/site-packages/livekit/agents/cli/__init__.py", line 1, in <module> 3.263 from .cli import AgentsConsole, run_app 3.263 File "/home/appuser/.local/lib/python3.11/site-packages/livekit/agents/cli/cli.py", line 42, in <module> 3.263 from ..job import JobExecutorType 3.263 File "/home/appuser/.local/lib/python3.11/site-packages/livekit/agents/job.py", line 41, in <module> 3.263 from .telemetry import _upload_session_report, trace_types, tracer 3.263 File "/home/appuser/.local/lib/python3.11/site-packages/livekit/agents/telemetry/__init__.py", line 2, in <module> 3.264 from .traces import _setup_cloud_tracer, _upload_session_report, set_tracer_provider, tracer 3.264 File "/home/appuser/.local/lib/python3.11/site-packages/livekit/agents/telemetry/traces.py", line 18, in <module> 3.264 from opentelemetry.sdk._logs import ( 3.264 ImportError: cannot import name 'LogData' from 'opentelemetry.sdk._logs' (/home/appuser/.local/lib/python3.11/site-packages/opentelemetry/sdk/_logs/__init__.py)
t
Thanks — this stack trace confirms the failure happens inside
livekit-agents
when it imports
LogData
from OpenTelemetry. Two practical options: • If you want the fastest fix, pin OpenTelemetry to a pre-1.20 release that still provides
LogData
. Add or update in your Dockerfile (or requirements):
Copy code
RUN pip install "opentelemetry-sdk<1.20.0"
Then rebuild the image. • If you prefer a long-term fix, update to OpenTelemetry ≥1.20.0 and make sure
livekit-agents
(or any package importing
LogData
) is updated or refactored to use
LogRecord
instead. That requires either: ◦ Upgrading
livekit-agents
to a version that supports the new logging API, or ◦ Editing the telemetry code to replace
LogData
imports/usages with
LogRecord
and adapt any call sites. Tell me which you prefer and paste the
pip install
line(s) or your requirements.txt from the Dockerfile — I’ll give the exact Dockerfile change or the minimal code edits you’ll need.
c
@eager-pager-29628 hey how did you fix this?
t
You're asking how to fix the ImportError — others (including Miguel) fixed it one of two ways. Which approach you want depends on whether you prefer a quick unblock or a long-term fix: Option A — Quick fix (recommended if you need to run now) • Pin OpenTelemetry to a pre-1.20 release that still exposes
LogData
. • In your Dockerfile (or requirements.txt) add:
Copy code
RUN pip install "opentelemetry-sdk<1.20.0"
• Rebuild the image. This resolves the import inside
livekit-agents
immediately. Option B — Long-term fix (recommended if you can change code or upgrade packages) • Upgrade OpenTelemetry to >=1.20.0 and ensure
livekit-agents
(or any package importing
LogData
) is updated to a version that uses
LogRecord
instead of
LogData
. • Or edit the telemetry code to replace:
Copy code
from opentelemetry.sdk._logs import LogData
with
Copy code
from opentelemetry.sdk._logs import LogRecord
and adjust uses to match the new API. Tell me which option you want to apply and paste the
pip install
line(s)` or your requirements.txt from the Dockerfile — I’ll give the exact Dockerfile change or the minimal code edits and commands to rebuild.