microsoft / debugpy

An implementation of the Debug Adapter Protocol for Python
https://pypi.org/project/debugpy/
Other
1.83k stars 136 forks source link

'PathDistribution' object has no attribute 'name' #1643

Open kazeki opened 2 months ago

kazeki commented 2 months ago

python version:

3.8.19

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
        }
    ]
}

error message

E+00000.072: Error while enumerating installed packages.

             Traceback (most recent call last):
               File "/home/xhdev/.vscode/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../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 "/home/xhdev/dev/miniconda3/envs/ML/lib/python3.8/runpy.py", line 194, in _run_module_as_main
                 return _run_code(code, main_globals, None,
               File "/home/xhdev/dev/miniconda3/envs/ML/lib/python3.8/runpy.py", line 87, in _run_code
                 exec(code, run_globals)
               File "/home/xhdev/.vscode/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/__main__.py", line 91, in <module>
                 main()
               File "/home/xhdev/.vscode/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/__main__.py", line 21, in main
                 log.describe_environment("debugpy.launcher startup environment:")
               File "/home/xhdev/.vscode/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/common/log.py", line 370, in describe_environment
                 info("{0}", get_environment_description(header))
               File "/home/xhdev/.vscode/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/common/log.py", line 364, in get_environment_description
                 swallow_exception("Error while enumerating installed packages.")
               File "/home/xhdev/.vscode/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/common/log.py", line 215, in swallow_exception
                 _exception(format_string, *args, **kwargs)
yedemon commented 2 months ago

I seem to have the same problem. But in my case, it seems only to be a "warning" message while not affecting the debug process, still annoying. Oh, I'm just happened to use miniconda too.

yedemon commented 1 month ago

I did some look into this crazy.. My only guess is it might has something related with packages installed. One of my project has those packages installed has this problem, while the others don't..

The env has the problem.

>pip list

Package Version


contourpy 1.1.1 cycler 0.12.1 fonttools 4.53.1 kiwisolver 1.4.5 matplotlib 3.7.5 numpy 1.24.4 opencv-python 4.10.0.84 packaging 24.1 pillow 10.4.0 pip 24.2 pyparsing 3.1.4 python-dateutil 2.9.0.post0 setuptools 72.1.0 six 1.16.0 wheel 0.43.0 zipp 3.20.1

The env doesn't have the problem.

>pip list

Package Version


asgiref 3.8.1 Django 5.1 image 1.5.33 numpy 2.1.0 opencv-python 4.10.0.84 pillow 10.4.0 pip 24.2 scipy 1.14.1 setuptools 72.1.0 six 1.16.0 sqlparse 0.5.1 typing_extensions 4.12.2 wheel 0.43.0

And both of the envs are brought up by "conda create --name *** python=3.8"

Dunno if these info will mislead, I am only want to help..

yedemon commented 1 month ago

Ek.. a few struggle😒. After installing a package called "importlib_metadata==8.4.0" to the project which has the problem. The message "'PathDistribution' object has no attribute 'name'" disappears..

Try: pip install "importlib_metadata==8.4.0"

I hope this works for your situation.❤

Still don't know where the problem lies.