如何使用Kivy和Mapview部署PyCharm项目? [英] How to deploy a PyCharm project with Kivy and mapview?
问题描述
我想用Kivy和MapView部署一个Python项目.我使用PyCharm进行开发,当我用它运行项目时,一切都很好. 我还尝试使用python IDLE编译并运行我的项目,它也很好用!
I want to deploy a Python Project with Kivy and a MapView. I develop with PyCharm and when I run my project with it, everything works well. I also tried to compile and run my project with the python IDLE, it also works good !
我遵循了PyInstaller的说明( https://www.pyinstaller.org/#pyinstaller-快速入门)并创建了文件夹.问题是我的.exe文件不起作用... cmd窗口已打开,但立即关闭..
I followed the instructions of PyInstaller (https://www.pyinstaller.org/#pyinstaller-quickstart) and the folders were created. The problem is that my .exe file doesn't works... A cmd window is opened but it's immediately closed..
如果您需要更多说明,请告诉我:)谢谢!
If you need more explanation, just let me know :) thanks !
推荐答案
这是我的main.py
:
from mapview import MapView, MapMarker
from kivy.app import App
class MapViewApp(App):
def build(self):
map = MapView(zoom=15, lat=39.566848, lon=-76.377053, double_tap_zoom=True)
marker_1 = MapMarker(lat=39.566848, lon=-76.377053, source='marker.png')
map.add_marker(marker_1)
return map
MapViewApp().run()
和我的main.spec
文件:
# -*- mode: python ; coding: utf-8 -*-
from kivy.deps import sdl2, glew
block_cipher = None
a = Analysis(['main.py'],
pathex=['C:\\Users\\John\\Documents\\PyCharmProjects\\MapViewPlay'],
binaries=[],
datas=[('marker.png', '.')],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True )
还有我的目录结构:
-MapViewPlay
main.py
main.spec
-mapview
__init__.py
types.py
utils.py
.
.
.
上面的mapview
文件夹是刚刚复制到其中的garden\garden.mapview\mapview
文件夹(使用garden install --app mapview
安装),其余的garden
文件夹已删除.我认为这是一个hack.您不必这样做,但是建议的方法却行不通.我以pyinstaller main.spec
身份运行pyinstaller
.
The mapview
folder above is the garden\garden.mapview\mapview
folder (installed using garden install --app mapview
) just copied there and the rest of the garden
folder removed. I consider this a hack. You shouldn't have to do it this way, but doing it the recommended way does not work. I run pyinstaller
as pyinstaller main.spec
.
这篇关于如何使用Kivy和Mapview部署PyCharm项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!