Skip to content

Debugger cannot import custom packages from directory other than that of main file #57

@mlangiu

Description

@mlangiu

It appears that python-debugger cannot be used to debug custom packages; steps to reproduce:

  • Set up the following directory structure, e.g., in /tmp/example:
    ├── maindir
    │   └── main.py
    └── mypackage
        └── __init__.py
    
  • contents of main.py
import os
print(os.listdir())
import mypackage  # or similarly from . import mypackage
  • contents of __init__.py
print("This worked!")
  • Open main.py in atom
  • Launch a debugger with the following options:
    • Program: /tmp/example/maindir/main.py
    • Python Path: /usr/local/bin/python3
    • Cwd: /tmp/example
    • Automatically Stop after launch
  • Hit F8 to start
  • Now for some reason I need to type something into the debugger's console and execute it to get the debugger running this may be an issue of itself!
  • executing the second line of main.py confirms that I am in /tmp/example/ yet executing the third one fails with
    Traceback (most recent call last):
    Python Debugger
    4:07:41 PM
    File "/tmp/example/maindir/main.py", line 3, in <module>
    Python Debugger
    4:07:41 PM
      import mypackage
    Python Debugger
    4:07:41 PM
    ModuleNotFoundError: No module named 'mypackage'
  • when moving main.py to Cwx (/tmp/example) the import works!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions