How to do relative imports in Python?

前端 未结 15 2884
情深已故
情深已故 2020-11-21 04:47

Imagine this directory structure:

app/
   __init__.py
   sub1/
      __init__.py
      mod1.py
   sub2/
      __init__.py
      mod2.py

I\'

15条回答
  •  故里飘歌
    2020-11-21 05:27

    You have to append the module’s path to PYTHONPATH:

    export PYTHONPATH="${PYTHONPATH}:/path/to/your/module/"
    

提交回复
热议问题