Skip to content

VS Code Debug Error #57

@StefanGreve

Description

@StefanGreve

Describe the bug
It is currently not possible to debug the module in VS Code using the launch.json settings from the documentation. The error message currently reads:

Exception has occurred: ImportError
attempted relative import with no known parent package
  File "C:\Users\stefan.greve\Desktop\repos\private\anonpy\src\anonpy\__main__.py", line 15, in <module>
    from .anonpy import AnonPy, Endpoint
ImportError: attempted relative import with no known parent package

To Reproduce

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "AnonPy CLI",
            "type": "python",
            "request": "launch",
            "module": "anonpy",
            "justMyCode": true,
            "args": [
                "preview",
                "--resource",
                "Aozkv26f"
            ]
        },
        {
            "name": "AnonPy Script",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "justMyCode": true,
            "console": "integratedTerminal"
        }
    ]
}

Expected behavior
Start and execute the VS Code debugger.

Screenshots
Additional Information

  • Module Version: 1.0.0-rc.2
  • Python Version: 3.12
  • Operating System: Windows 10

Additional context
Links relevant to the problem:

This problem is also reproducible on the master branch and 1.0.0-rc.1.

The same error message appears when running this command:

python -X importtime .\src\anonpy\__main__.py
Traceback (most recent call last):
  File "C:\Users\stefan.greve\Desktop\repos\private\anonpy\src\anonpy\__main__.py", line 14, in <module>
    from .anonpy import AnonPy, Endpoint
ImportError: attempted relative import with no known parent package

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is neededminorIssues rated with a low priority

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions