Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

DistributionNotFound error potentially caused by pkg_resources #482

@dionearle

Description

@dionearle

Hi,

I posted a similar issue in the bigquery project (googleapis/python-bigquery#1307) but decided I should also post it here since this is the package causing issues.

When using this package on my local machine I have no issues, however when deploying to our serverless environment in an AWS lambda we get the error seen at the bottom of this issue.

We have tried numerous changes, such as using the same version of pip being used locally, and disabling slim in the serverless python requirements, but the issue is still happening. Locally we use poetry to install packages.

When looking at the error message, the issue seems to be around pkg_resources, and from looking at other google packages I can see similar issues have been encountered and resolved around this. Is it possible to do something similar here? We are currently blocked from using this package until this issue is resolved.

Related issues from other projects:
googleapis/python-api-core#27
https://github.com/googleapis/google-api-python-client/pull/1623/files

Environment details

  • OS type and version: Linux on a docker container
  • Python version: 3.7.10
  • pip version: 22.0.4
  • google-cloud-bigquery-storage version: 2.14.1

Steps to reproduce

  1. Deploy the build and attempt to run any code

Stack trace

{
  "errorMessage": "The 'google-cloud-bigquery-storage' distribution was not found and is required by the application",
  "errorType": "DistributionNotFound",
  "stackTrace": [
    "  File \"/var/lang/lib/python3.7/imp.py\", line 234, in load_module\n    return load_source(name, filename, file)\n",
    "  File \"/var/lang/lib/python3.7/imp.py\", line 171, in load_source\n    module = _load(spec)\n",
    "  File \"<frozen importlib._bootstrap>\", line 696, in _load\n",
    "  File \"<frozen importlib._bootstrap>\", line 677, in _load_unlocked\n",
    "  File \"<frozen importlib._bootstrap_external>\", line 728, in exec_module\n",
    "  File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\n",
    "  File \"/opt/python/lib/python3.7/site-packages/datadog_lambda/handler.py\", line 27, in <module>\n    handler_module = import_module(mod_name)\n",
    "  File \"/var/lang/lib/python3.7/importlib/__init__.py\", line 127, in import_module\n    return _bootstrap._gcd_import(name[level:], package, level)\n",
    "  File \"<frozen importlib._bootstrap>\", line 1006, in _gcd_import\n",
    "  File \"<frozen importlib._bootstrap>\", line 983, in _find_and_load\n",
    "  File \"/opt/python/lib/python3.7/site-packages/ddtrace/internal/import_hooks.py\", line 215, in wrapped_find_and_load_unlocked\n    return exec_and_call_hooks(module_name, wrapped, args, kwargs)\n",
    "  File \"/opt/python/lib/python3.7/site-packages/ddtrace/internal/import_hooks.py\", line 171, in exec_and_call_hooks\n    return wrapped(*args, **kwargs)\n",
    "  File \"<frozen importlib._bootstrap>\", line 967, in _find_and_load_unlocked\n",
    "  File \"<frozen importlib._bootstrap>\", line 677, in _load_unlocked\n",
    "  File \"<frozen importlib._bootstrap_external>\", line 728, in exec_module\n",
    "  File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\n",
    "  File \"/var/task/handlers/functions/voz_rf.py\", line 10, in <module>\n    from google.cloud.bigquery import Client\n",
    "  File \"<frozen importlib._bootstrap>\", line 983, in _find_and_load\n",
    "  File \"/opt/python/lib/python3.7/site-packages/ddtrace/internal/import_hooks.py\", line 215, in wrapped_find_and_load_unlocked\n    return exec_and_call_hooks(module_name, wrapped, args, kwargs)\n",
    "  File \"/opt/python/lib/python3.7/site-packages/ddtrace/internal/import_hooks.py\", line 171, in exec_and_call_hooks\n    return wrapped(*args, **kwargs)\n",
    "  File \"/tmp/sls-py-req/google/cloud/bigquery/__init__.py\", line 35, in <module>\n    from google.cloud.bigquery.client import Client\n",
    "  File \"<frozen importlib._bootstrap>\", line 983, in _find_and_load\n",
    "  File \"/opt/python/lib/python3.7/site-packages/ddtrace/internal/import_hooks.py\", line 215, in wrapped_find_and_load_unlocked\n    return exec_and_call_hooks(module_name, wrapped, args, kwargs)\n",
    "  File \"/opt/python/lib/python3.7/site-packages/ddtrace/internal/import_hooks.py\", line 171, in exec_and_call_hooks\n    return wrapped(*args, **kwargs)\n",
    "  File \"/tmp/sls-py-req/google/cloud/bigquery/client.py\", line 59, in <module>\n    from google.cloud.bigquery_storage_v1.services.big_query_read.client import (\n",
    "  File \"<frozen importlib._bootstrap>\", line 983, in _find_and_load\n",
    "  File \"/opt/python/lib/python3.7/site-packages/ddtrace/internal/import_hooks.py\", line 215, in wrapped_find_and_load_unlocked\n    return exec_and_call_hooks(module_name, wrapped, args, kwargs)\n",
    "  File \"/opt/python/lib/python3.7/site-packages/ddtrace/internal/import_hooks.py\", line 171, in exec_and_call_hooks\n    return wrapped(*args, **kwargs)\n",
    "  File \"<frozen importlib._bootstrap>\", line 983, in _find_and_load\n",
    "  File \"/opt/python/lib/python3.7/site-packages/ddtrace/internal/import_hooks.py\", line 215, in wrapped_find_and_load_unlocked\n    return exec_and_call_hooks(module_name, wrapped, args, kwargs)\n",
    "  File \"/opt/python/lib/python3.7/site-packages/ddtrace/internal/import_hooks.py\", line 171, in exec_and_call_hooks\n    return wrapped(*args, **kwargs)\n",
    "  File \"<frozen importlib._bootstrap>\", line 983, in _find_and_load\n",
    "  File \"/opt/python/lib/python3.7/site-packages/ddtrace/internal/import_hooks.py\", line 215, in wrapped_find_and_load_unlocked\n    return exec_and_call_hooks(module_name, wrapped, args, kwargs)\n",
    "  File \"/opt/python/lib/python3.7/site-packages/ddtrace/internal/import_hooks.py\", line 171, in exec_and_call_hooks\n    return wrapped(*args, **kwargs)\n",
    "  File \"<frozen importlib._bootstrap>\", line 983, in _find_and_load\n",
    "  File \"/opt/python/lib/python3.7/site-packages/ddtrace/internal/import_hooks.py\", line 215, in wrapped_find_and_load_unlocked\n    return exec_and_call_hooks(module_name, wrapped, args, kwargs)\n",
    "  File \"/opt/python/lib/python3.7/site-packages/ddtrace/internal/import_hooks.py\", line 171, in exec_and_call_hooks\n    return wrapped(*args, **kwargs)\n",
    "  File \"/tmp/sls-py-req/google/cloud/bigquery_storage_v1/__init__.py\", line 22, in <module>\n    \"google-cloud-bigquery-storage\"\n",
    "  File \"/opt/python/lib/python3.7/site-packages/pkg_resources/__init__.py\", line 481, in get_distribution\n    dist = get_provider(dist)\n",
    "  File \"/opt/python/lib/python3.7/site-packages/pkg_resources/__init__.py\", line 357, in get_provider\n    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]\n",
    "  File \"/opt/python/lib/python3.7/site-packages/pkg_resources/__init__.py\", line 900, in require\n    needed = self.resolve(parse_requirements(requirements))\n",
    "  File \"/opt/python/lib/python3.7/site-packages/pkg_resources/__init__.py\", line 786, in resolve\n    raise DistributionNotFound(req, requirers)\n"
  ]
}

Metadata

Metadata

Labels

api: bigquerystorageIssues related to the googleapis/python-bigquery-storage API.type: cleanupAn internal cleanup or hygiene concern.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions