Python在同一目录级别导入模块

时间:2019-09-19 15:07:10

标签: python python-2.7

我的python项目中具有以下包结构

wolv
   |---car
         |---cos
               |---
                __init__.py
                utils.py
                manager.py
         |---providers
                     |---sl.py
         | **utils.py**
         | config.py
         |__init__.py

wolv.car.utills.py中我可以执行from wolv.car import config,但不能执行from wolv.car.cos import manager任何原因为什么会发生,以及如何在wolv.car.utills.py中导入管理器

跟踪是:

Traceback (most recent call last):
  File "/usr/local/bin/wvbar-utils", line 6, in <module>
    from wolv.car.utils import main
  File "/usr/local/lib/python2.7/site-packages/wolv/car/utils.py", line 31, in <module>
    from wolv.car.cos import manager
  File "/usr/local/lib/python2.7/site-packages/wolv/car/cos/manager.py", line 10, in <module>
    from wolv.car.cos.providers import sl
  File "/usr/local/lib/python2.7/site-packages/wolv/car/cos/providers/sl.py", line 21, in <module>
    from wolv.car import utils
ImportError: cannot import name utils

manager.py具有from wolv.car.cos.providers import sl,而sl.py具有from wolv.car import utils

0 个答案:

没有答案