问题
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 !
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 !
回答1:
Here is my 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()
And my main.spec
file:
# -*- 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 )
And my directory structure:
-MapViewPlay
main.py
main.spec
-mapview
__init__.py
types.py
utils.py
.
.
.
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
.
来源:https://stackoverflow.com/questions/63107233/how-to-deploy-a-pycharm-project-with-kivy-and-mapview