发布时间:2022-08-09 文章分类:编程知识 投稿人:李佳 字号: 默认 | | 超大 打印

Ditch relative imports: you should think of your package namespace as a global one, anyway.

The trick to making this palatable is editing sys.path appropriately. Here is some food for thought:

# one directory up
_root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.insert(0, _root_dir)for now