【发布时间】:2014-05-04 10:35:30
【问题描述】:
我正在尝试编译MAVProxy,
运行
python mavproxy.py --master=/dev/ttyUSB0 --baudrate=57600
返回错误
Traceback(最近一次调用最后一次):
文件“mavproxy.py”,第 1151 行,在
mpstate = MPState()
文件“mavproxy.py”,第 114 行,在 init 中
从 MAVProxy.modules.lib.mp_settings 导入 MPSettings、MPSetting
ImportError: 无法导入名称 MPSetting
有一个__init__.py
目录架构是
MAV代理\
|- __init__.py
|-mavproxy.py
|-(其他文件
|- 模块\
|- __ init__.py |- (other files |- lib\ |- __ init__.py |- mp_settings.py
在mavproxy.py中
class MPState(object):
def __init__(self):
self.console = textconsole.SimpleConsole()
self.map = None
self.map_functions = {}
self.vehicle_type = None
self.vehicle_name = None
from MAVProxy.modules.lib.mp_settings import MPSettings, MPSetting
self.settings = MPSettings(
....
在 mp_settings.py 中:
#!/usr/bin/env python
class MPSetting:
....
class MPSettings(object):
....
只有mp_settings.py中的MPSetting不能导入, MPSettings 可以成功导入。
我尝试将导入代码从类内部移动到程序顶部,但仍然出现相同的错误:
ImportError: 无法导入名称 MPSetting
有什么建议我接下来应该尝试什么?
【问题讨论】:
标签: python python-2.7 import