python packaging for relative imports

前端 未结 3 1010
小蘑菇
小蘑菇 2020-11-29 19:18

First off all: I\'m sorry, I know there has been lots of question about relative imports, but I just didn\'t find a solution. If possible I would like to use the following d

3条回答
  •  情歌与酒
    2020-11-29 19:34

    Intra-package-references describes how to myClass from test/*. To import the package from outside, you should add its path to PYTHONPATH environment variable before running the importer application, or to sys.path list in the code before importing it.

    Why from ..src import myClass fails: probably, src is not a python package, you cannot import from there. You should add it to python path as described above.

提交回复
热议问题