使用api start app.py
初始化以下Flask网络服务器:
from flask import Flask
app = Flask(__name__)
给出错误:
Exception in APIThread-0: 'NoneType' object has no attribute 'startswith'
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/droneapi/module/api.py", line 333, in run
self.fn()
File "/usr/local/lib/python2.7/dist-packages/droneapi/module/api.py", line 625, in <lambda>
APIThread(self, lambda: execfile(args[1], g), args[1])
File "simple.py", line 2, in <module>
app = Flask(__name__)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 319, in __init__
template_folder=template_folder)
File "/usr/local/lib/python2.7/dist-packages/flask/helpers.py", line 741, in __init__
self.root_path = get_root_path(self.import_name)
File "/usr/local/lib/python2.7/dist-packages/flask/helpers.py", line 649, in get_root_path
return os.path.dirname(os.path.abspath(filepath))
File "/usr/lib/python2.7/posixpath.py", line 352, in abspath
if not isabs(path):
File "/usr/lib/python2.7/posixpath.py", line 61, in isabs
return s.startswith('/')
AttributeError: 'NoneType' object has no attribute 'startswith'
直接运行时它工作正常,并且在通过MavProxy运行时Cherrypy工作,所以我认为它是路径问题? Flask bootstrap此处列出了相同的错误,但裸Flask并不需要设置配置路径。
答案 0 :(得分:1)
DKPY2.0(刚发布)没有MAVProxy依赖 - 脚本是“独立运行”。因此,只要flask在您的Python环境中,这应该“正常工作”