Debugger can´t find project module, but Run can

I have a project (RB) with two sub-packages: RB/core and RB/tests. In the 'core' package, init.py imports RB/core/base.py, which then imports a wrapper function called 'timer' from RB/tests/code_timing.py to be used as a decorator to time its functions. The thing is that when I run the base.py file using PyCharm's Run mode, everything works, but when I try to run it from the Debugger, the following error is raised:

Traceback (most recent call last):


File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\pydev\pydevd.py", line 1741, in <module>
    main()
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\pydev\pydevd.py", line 1735, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\pydev\pydevd.py", line 1135, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Users/nicolas.fonteyne/SCRIPTS/RB/core/base.py", line 9, in <module>
    from tests.code_timing import timer
ModuleNotFoundError: No module named 'tests.code_timing'
1 comment

I see a similar issue when attempting to launch a python script from the main process (which is launched as a module with "-m").  It works under "Run", but under "Debug" it complains that it can't find module "script.py" and the subprocess fails to launch.

1

Please sign in to leave a comment.