镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
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

Closed

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"
  ]
}

Activity

  1. dionearle commented on Aug 9, 2022

    @dionearle
    Author

    I managed to create a fix for this in my own fork of python-bigquery-storage as seen in this commit.

    Would we be able to make a similar change in the main fork? If so I can create a pull request if the change is fine as is, otherwise it'd be great to have this implemented properly so we can go back to using the main version.

  2. skraelings commented on Nov 2, 2022

    @skraelings

    @dionearle blocked by the same issue, I have raised #531 which is similar to what other google libraries have done.

  3. self-assigned this
    on Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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