Python 3 - 找不到模块

Dim*_*rak 8 python importerror python-3.x

我有以下文件结构......

 > Boo
    > ---modA
    > ------__init__.py
    > ------fileAA.py
    > ---modB
    > ------__init__.py
    > ------fileBB.py
Run Code Online (Sandbox Code Playgroud)

当我在fileBB.py里面时

from modA.fileAA import <something>
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

from modA.fileAA import <something>
ModuleNotFoundError: No module named 'modA'
Run Code Online (Sandbox Code Playgroud)

请注意,__init__.py文件为空并使用Python 3.

我在这里错过了什么或做错了什么?

ker*_*son 1

这几乎肯定是PYTHONPATH您运行脚本的位置的问题。一般来说,这是有效的:

$ ls modA/
fileAA.py  __init__.py
$ cat modA/fileAA.py 
x = 1
$ python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from modA.fileAA import x
>>> x
1
Run Code Online (Sandbox Code Playgroud)

您可以查看sys.path以检查您的路径。