Skip to content

Address DeprecationWarning #3173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jenstroeger opened this issue Feb 15, 2023 · 6 comments
Closed

Address DeprecationWarning #3173

jenstroeger opened this issue Feb 15, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@jenstroeger
Copy link

jenstroeger commented Feb 15, 2023

Describe your environment

Python 3.10.10 on macOS Ventura 13.2

Steps to reproduce

What is the expected behavior?

The import succeeds.

What is the actual behavior?

The import fails:

.venv/lib/python3.10/site-packages/opentelemetry/instrumentation/grpc/__init__.py:282: in <module>
    from opentelemetry import trace
.venv/lib/python3.10/site-packages/opentelemetry/trace/__init__.py:87: in <module>
    from opentelemetry import context as context_api
.venv/lib/python3.10/site-packages/opentelemetry/context/__init__.py:22: in <module>
    from pkg_resources import iter_entry_points
.venv/lib/python3.10/site-packages/pkg_resources/__init__.py:3257: in <module>
    def _initialize_master_working_set():
.venv/lib/python3.10/site-packages/pkg_resources/__init__.py:3231: in _call_aside
    f(*args, **kwargs)
.venv/lib/python3.10/site-packages/pkg_resources/__init__.py:3282: in _initialize_master_working_set
    tuple(dist.activate(replace=False) for dist in working_set)
.venv/lib/python3.10/site-packages/pkg_resources/__init__.py:3282: in <genexpr>
    tuple(dist.activate(replace=False) for dist in working_set)
.venv/lib/python3.10/site-packages/pkg_resources/__init__.py:2803: in activate
    declare_namespace(pkg)
.venv/lib/python3.10/site-packages/pkg_resources/__init__.py:2297: in declare_namespace
    warnings.warn(msg, DeprecationWarning, stacklevel=2)
E   DeprecationWarning: Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages

Additional context

For the time being I filter that warning with

PYTHONWARNINGS="always::DeprecationWarning:pkg_resources"

but it should probably be addressed.

@jenstroeger jenstroeger added the bug Something isn't working label Feb 15, 2023
@jenshnielsen
Copy link
Contributor

Opentelemetry dropped the use of pkg_resources in #3047 so I think this is already fixed in the main branch.

As far as I understand the problem with pkg_resources is that is scans all installed packages so the namespace package could be any package in your environment. See the note in the setuptools docs

@jenshnielsen
Copy link
Contributor

jenshnielsen commented Feb 15, 2023

The actual origin of the warning is likely googleapis-common-protos if you have that installed https://github.com/googleapis/python-api-common-protos/blob/main/google/rpc/__init__.py

Also see googleapis/python-api-common-protos#140

@jenstroeger
Copy link
Author

Thanks @jenshnielsen! Indeed the googleapis-common-protos is installed, nice catch!

Feel free to close this issue then.

@srikanthccv srikanthccv closed this as not planned Won't fix, can't repro, duplicate, stale Feb 16, 2023
@sk-
Copy link
Contributor

sk- commented Apr 20, 2023

But that's a dependency of opentelemetry-exporter-otlp-proto-grpc. See

Not sure if it's possible for OpenTelemetry to silence that warning somehow. Or maybe a better option could be to stop depending on that package and instead just bring the protos used to the opentelemetry repo. The only used proto from google that I found is RetryInfo

@2zqa
Copy link

2zqa commented Jan 31, 2024

Can reproduce, please re-open this issue. As mentioned above this project uses v1.52 which is a 4 year old version and could use updating anyway. Updating to v1.62.0 will close this issue.

EDIT: this might be solved automatically once a new version is released that uses v1.62.0, since the ~= version identifier is used

@sk-
Copy link
Contributor

sk- commented Mar 16, 2024

If anyone is still having this issue, you can fix it by forcing an update of googleapis-common-protos. We bumped it to version 1.63.0 and the warnings are gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants