Skip to content
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

Error while enumerating installed packages. #1379

Closed
ttSpace opened this issue Sep 8, 2023 · 13 comments
Closed

Error while enumerating installed packages. #1379

ttSpace opened this issue Sep 8, 2023 · 13 comments
Assignees
Labels
bug Something isn't working P1

Comments

@ttSpace
Copy link

ttSpace commented Sep 8, 2023

Describe the bug

image

Steps to Reproduce

  1. Create a Python Application project.
  2. Type
import debugpy
print(debugpy.__version__)
debugpy.listen(("localhost", 5678))
debugpy.wait_for_client()
print('hello')
  1. Set a breakpoint on the print('hello'). (Note: Install debugpy in the current environment.)
  2. Start Without Debugging.

Expected behavior

No error.

Additional context and screenshots

Error while enumerating installed packages.

image

Logs

1.7.0
E+00000.047: Error while enumerating installed packages.

             Traceback (most recent call last):
               File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\lib\site-packages\debugpy\common\log.py", line 361, in get_environment_description
                 report("    {0}=={1}\n", pkg.name, pkg.version)
             AttributeError: 'PathDistribution' object has no attribute 'name'

             Stack where logged:
               File "C:\Users\vting\source\repos\PythonApplication2\PythonApplication2\PythonApplication2.py", line 4, in <module>
                 debugpy.listen(("localhost", 5678))
               File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\lib\site-packages\debugpy\public_api.py", line 31, in wrapper
                 return wrapped(*args, **kwargs)
               File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\lib\site-packages\debugpy\server\api.py", line 122, in debug
                 ensure_logging()
               File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\lib\site-packages\debugpy\server\api.py", line 61, in ensure_logging
                 log.describe_environment("Initial environment:")
               File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\lib\site-packages\debugpy\common\log.py", line 369, in describe_environment
                 info("{0}", get_environment_description(header))
               File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\lib\site-packages\debugpy\common\log.py", line 363, in get_environment_description
                 swallow_exception("Error while enumerating installed packages.")
               File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\lib\site-packages\debugpy\common\log.py", line 215, in swallow_exception
                 _exception(format_string, *args, **kwargs)

@StellaHuang95
Copy link
Contributor

Could you also install the importlib-metadata and try again?

@int19h int19h transferred this issue from microsoft/PTVS Sep 8, 2023
@int19h int19h self-assigned this Sep 8, 2023
@int19h int19h added bug Something isn't working P0 The issue is important, and should be prioritized for new work. and removed waiting for response labels Sep 8, 2023
@int19h
Copy link
Contributor

int19h commented Sep 8, 2023

If importlib-metadata is installed, try upgrading it. It seems that there are some incompatibilities of older versions with some packages.

@int19h int19h added P1 and removed P0 The issue is important, and should be prioritized for new work. labels Sep 8, 2023
@int19h
Copy link
Contributor

int19h commented Sep 8, 2023

@ttSpace Can you please try the following. Locate debugpy/common/log.py under site-packages (following the path you see in the output). Find the line in that file that says:

swallow_exception("Error while enumerating installed packages.")

replace it with:

swallow_exception("Error while enumerating installed packages.", level="info")

Does that help?

@ttSpace
Copy link
Author

ttSpace commented Sep 11, 2023

@int19h @StellaHuang95

No errors after installing importlib-metadata.

image

@ttSpace Can you please try the following. Locate debugpy/common/log.py under site-packages (following the path you see in the output). Find the line in that file that says:

swallow_exception("Error while enumerating installed packages.")

replace it with:

swallow_exception("Error while enumerating installed packages.", level="info")

Does that help?

No errors after replacement.

image

@mingp
Copy link

mingp commented Sep 11, 2023

I am encountering the same issue. For whatever it's worth, I tried upgrading importlib-metadata, and it did not help.

My installed versions are as follows:

debugpy==1.7.0

importlib-metadata==4.11.3 # before upgrade
importlib-metadata==6.8.0 # after upgrade

Because I'm encountering this issue in a work codebase, whose dependencies are managed using Bazel, it's not easy for me to swap out a locally-vendored version to test that.

@mingp
Copy link

mingp commented Sep 11, 2023

I downgraded the version of debugpy as follows:

debugpy==1.6.7

This at least avoids this particular issue. Putting this here in case it might help anyone else.

But, it's unclear to me yet if it's working end-to-end, because I have not yet been able to connect VS Code, and it's unclear to me yet if that's an error on my part.

@int19h
Copy link
Contributor

int19h commented Sep 11, 2023

It should not affect operation other than the message being printed.

debugpy itself doesn't have any dependencies other than the Python stdlib, and is runnable directly from the repo tree (i.e. you should be able to just clone or copy the source directory and then do python src/debugpy to run it from command line). I'm pretty sure that the above line would be sufficient to fix it but I'd love to test it before pushing out an update.

@mingp
Copy link

mingp commented Sep 11, 2023

I was able to get the VS Code debugger working end-to-end on debugpy==1.6.7. Putting this here in case it might help anyone else.

int19h pushed a commit to int19h/debugpy that referenced this issue Sep 11, 2023
When logging environment info, report all errors at "info" level.
@int19h int19h closed this as completed in cbd0c2a Sep 12, 2023
@SushNag
Copy link

SushNag commented Feb 6, 2024

@ttSpace Can you please try the following. Locate debugpy/common/log.py under site-packages (following the path you see in the output). Find the line in that file that says:

swallow_exception("Error while enumerating installed packages.")

replace it with:

swallow_exception("Error while enumerating installed packages.", level="info")

Does that help?

This worked for me, Thanks

@fartzy
Copy link

fartzy commented Feb 9, 2024

debugpy==1.6.7

Thank you so much, yes this worked for me too

@styk-tv
Copy link

styk-tv commented Feb 11, 2024

Could you also install the importlib-metadata and try again?

2 hours of wasted life. typical microsoft - above fixed error conda install importlib-metadata

@int19h
Copy link
Contributor

int19h commented Feb 12, 2024

The workaround should not be necessary on current debugpy versions. Please let me know if you're running into some issue.

@bearrito
Copy link

Is this fixed with the extension?

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

No branches or pull requests

8 participants