简体   繁体   中英

pdb unable to use from currentdir import mod

Here is the current directory setup:

dir_a:
  __init__.py
  one.py
  two.py

Here is one.py:

from dir_a.two import TwoClass

From inside dir_a, running

"python -m pdb one.py" 
"ModuleNotFoundError: No module named 'dir_a'"

From inside pdb, I've tried appending the absolute path to dir_a, but still having trouble finding and being able to import my Two class.

Two options:

  1. From directory containing dir_a: export PYTHONPATH="${PYTHONPATH}:$(pwd)"
  2. In pdb: import sys; sys.path.append('[dir containing dir_a]') import sys; sys.path.append('[dir containing dir_a]')

Don't add the dir_a path itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM