atom-python-debugger icon indicating copy to clipboard operation
atom-python-debugger copied to clipboard

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

Open mlangiu opened this issue 5 years ago • 0 comments

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!

mlangiu avatar Aug 13 '20 14:08 mlangiu