你如何在Kivy中正确导入MapSource?

时间:2018-03-12 13:15:54

标签: python linux raspberry-pi kivy

我正在克隆一个使用Kivy快速原型作为其界面的存储库。它是一年前的最后更新,原始开发人员没有回应问题 - 我想我会在这里问。

该程序使用MapSource库,并按如下方式导入:

#:import MapSource mapview.MapSource

我收到错误:

Unable to import package 'mapview.MapSource'

这是我第一次与Kivy合作。导入MapSource的语法是什么?

以下是错误的完整输出:

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/kivy/lang/parser.py", line 464, 
in execute_directives
mod = import('.'.join(package.split('.')[:-1]))
File "/home/pi/CoPilot/mapview/init.py", line 30, in 
from mapview.source import MapSource
File "/home/pi/CoPilot/mapview/source.py", line 8, in 
from mapview.downloader import Downloader
File "/home/pi/CoPilot/mapview/downloader.py", line 8, in 
from concurrent.futures import ThreadPoolExecutor, TimeoutError, as_completed
ImportError: No module named concurrent.futures
Traceback (most recent call last):
File "main.py", line 2077, in 
MainApp().run()
File "/usr/local/lib/python2.7/dist-packages/kivy/app.py", line 799, in run
self.load_kv(filename=self.kv_file)
File "/usr/local/lib/python2.7/dist-packages/kivy/app.py", line 596, in load_kv
root = Builder.load_file(rfilename)
File "/usr/local/lib/python2.7/dist-packages/kivy/lang/builder.py", line 301, in load_file
return self.load_string(data, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/kivy/lang/builder.py", line 350, in load_string
parser = Parser(content=string, filename=fn)
File "/usr/local/lib/python2.7/dist-packages/kivy/lang/parser.py", line 392, in init
self.parse(content)
File "/usr/local/lib/python2.7/dist-packages/kivy/lang/parser.py", line 498, in parse
self.execute_directives()
File "/usr/local/lib/python2.7/dist-packages/kivy/lang/parser.py", line 475, in execute_directives
package)
kivy.lang.parser.ParserException: Parser: File "/home/pi/CoPilot/main.kv", line 31:
...
29:#:import MDThemePicker kivymd.theme_picker.MDThemePicker
30:#:import math math

31:#:import MapSource mapview.MapSource
32:
33:#on_press: Animation(x=newposition or y=newposition).start(id) #to animate things
...
Unable to import package 'mapview.MapSource'

这是存储库的链接:

Repository for CoPilot

谢谢大家的帮助。谢谢!

1 个答案:

答案 0 :(得分:0)

你当然想要garden.mapview

要安装它,你可以使用garden kivy工具来安装kivy模块,如果已经安装了garden(应该是你安装kivy的情况),它应该就这么简单。

garden install --app mapview

--app不是强制性的,只是将花放在app dir而不是〜/ .kivy / garden中

如果没有,您可以pip install kivy-garden或者您可以在应用中创建lib目录并在其中创建git clone git@github.com:kivy-garden/garden.mapview.git,因为这是该工具的功能。