Can';安装一个Kivy python程序

Can';安装一个Kivy python程序,python,pycharm,anaconda,kivy,pyinstaller,Python,Pycharm,Anaconda,Kivy,Pyinstaller,我无法让pyinstaller用我的python代码创建.exe 我想这一定是因为 我用Kivy做这个产品,而且 B:我想用anaconda作为我的python解释器 有一段时间,它会生成.exe,但当我启动它时,它会给出一系列关于没有可用窗口的错误。 我尝试安装/卸载软件包,在我的编辑器(PyCharm)上重新设置python解释器,最后我重新安装了anaconda。现在,当我尝试运行它时,它甚至不会创建.exe,它只会给我一个错误 这是我在终端上运行的命令 (venv) C:\Users\L

我无法让pyinstaller用我的python代码创建.exe

我想这一定是因为

我用Kivy做这个产品,而且

B:我想用anaconda作为我的python解释器

有一段时间,它会生成.exe,但当我启动它时,它会给出一系列关于没有可用窗口的错误。 我尝试安装/卸载软件包,在我的编辑器(PyCharm)上重新设置python解释器,最后我重新安装了anaconda。现在,当我尝试运行它时,它甚至不会创建.exe,它只会给我一个错误

这是我在终端上运行的命令

(venv) C:\Users\Luc\PycharmProjects\GoogleCommandCenter>pyinstaller --onefile main.spec
这是我收到的错误信息

895 INFO: PyInstaller: 3.3.1
896 INFO: Python: 3.6.4
896 INFO: Platform: Windows-10-10.0.16299-SP0
898 INFO: UPX is not available.
900 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Luc\\PycharmProjects\\GoogleCommandCenter',
 'C:\\Users\\Luc\\PycharmProjects\\GoogleCommandCenter',
 'C:\\Users\\Luc\\PycharmProjects\\GoogleCommandCenter\\venv',
 'C:\\Users\\Luc\\PycharmProjects\\GoogleCommandCenter\\venv\\Scripts\\python.exe']
901 INFO: checking Analysis
901 INFO: Building Analysis because out00-Analysis.toc is non existent
901 INFO: Initializing module dependency graph...
907 INFO: Initializing module graph hooks...
910 INFO: Analyzing base_library.zip ...
4627 INFO: running Analysis out00-Analysis.toc
4629 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\luc\pycharmprojects\googlecommandcenter\venv\scripts\python.exe
5229 INFO: Caching module hooks...
5233 INFO: Analyzing main.py
8793 INFO: Processing pre-find module path hook   distutils
8795 INFO: distutils: retargeting to non-venv dir 'C:\\Users\\Luc\\Anaconda3\\Lib\\distutils'
10009 INFO: Processing pre-find module path hook   site
10010 INFO: site: retargeting to fake-dir 'c:\\users\\luc\\pycharmprojects\\googlecommandcenter\\venv\\lib\\site-packages\\PyInstaller\\fake-modules'
18352 INFO: Processing pre-safe import module hook   six.moves
21522 INFO: Loading module hooks...
21523 INFO: Loading module hook "hook-distutils.py"...
21524 INFO: Loading module hook "hook-encodings.py"...
21614 INFO: Loading module hook "hook-kivy.py"...
Purge log fired. Analysing...
Purge 23 log files
Purge finished!
[INFO   ] [Logger      ] Record log in C:\Users\Luc\.kivy\logs\kivy_18-04-12_0.txt
21657 INFO: [Logger      ] Record log in C:\Users\Luc\.kivy\logs\kivy_18-04-12_0.txt
[INFO   ] [Kivy        ] v1.10.0
21627 INFO: [Kivy        ] v1.10.0
[INFO   ] [Python      ] v3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)]
21657 INFO: [Python      ] v3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)]
[INFO   ] [Factory     ] 194 symbols loaded
21660 INFO: [Factory     ] 194 symbols loaded
[INFO   ] [Logger      ] Record log in C:\Users\Luc\.kivy\logs\kivy_18-04-12_21.txt
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)]
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[INFO   ] [Logger      ] Record log in C:\Users\Luc\.kivy\logs\kivy_18-04-12_22.txt
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)]
[INFO   ] [AudioGstplayer] Using Gstreamer 1.10.2.0
[INFO   ] [Audio       ] Providers: audio_gstplayer, audio_sdl2 (audio_ffpyplayer ignored)
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[CRITICAL] [Camera      ] Unable to find any valuable Camera provider.
opencv - ModuleNotFoundError: No module named 'cv2'
  File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\kivy\core\camera\camera_opencv.py", line 45, in <module>
    import cv2

[INFO   ] [Clipboard   ] Provider: winctypes
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [OSC         ] using <thread> for socket
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL" graphics system
[INFO   ] [GL          ] GLEW initialization succeeded
[INFO   ] [GL          ] Backend used <glew>
[INFO   ] [GL          ] OpenGL version <b'4.6.0 NVIDIA 388.13'>
[INFO   ] [GL          ] OpenGL vendor <b'NVIDIA Corporation'>
[INFO   ] [GL          ] OpenGL renderer <b'GeForce GTX 750 Ti/PCIe/SSE2'>
[INFO   ] [GL          ] OpenGL parsed version: 4, 6
[INFO   ] [GL          ] Shading version <b'4.60 NVIDIA'>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <32>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[CRITICAL] [Spelling    ] Unable to find any valuable Spelling provider.
enchant - ModuleNotFoundError: No module named 'enchant'
  File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\kivy\core\spelling\spelling_enchant.py", line 6, in <module>
    import enchant

[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [VideoGstplayer] Using Gstreamer 1.10.2.0
[INFO   ] [Video       ] Provider: gstplayer
28584 INFO: Import to be excluded not found: '_tkinter'
28584 INFO: Import to be excluded not found: 'tkinter'
28584 INFO: Excluding import 'twisted'
28588 INFO:   Removing import of twisted from module kivy.support
28589 INFO: Loading module hook "hook-lib2to3.py"...
28592 INFO: Loading module hook "hook-numpy.core.py"...
Traceback (most recent call last):
  File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
    from . import multiarray
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
    from . import add_newdocs
  File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
    from .type_check import *
  File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
    raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: DLL load failed: The specified module could not be found.

 Traceback (most recent call last):
28814 WARNING: stderr: Traceback (most recent call last):
   File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
28815 WARNING: stderr:   File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
     from . import multiarray
28816 WARNING: stderr:     from . import multiarray
 ImportError: DLL load failed: The specified module could not be found.
28817 WARNING: stderr: ImportError: DLL load failed: The specified module could not be found.

28824 WARNING: stderr:
 During handling of the above exception, another exception occurred:
28824 WARNING: stderr: During handling of the above exception, another exception occurred:

28825 WARNING: stderr:
 Traceback (most recent call last):
28826 WARNING: stderr: Traceback (most recent call last):
   File "C:\Users\Luc\Anaconda3\Lib\pkgutil.py", line 490, in find_loader
28827 WARNING: stderr:   File "C:\Users\Luc\Anaconda3\Lib\pkgutil.py", line 490, in find_loader
     spec = importlib.util.find_spec(fullname)
28827 WARNING: stderr:     spec = importlib.util.find_spec(fullname)
   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\importlib\util.py", line 88, in find_spec
28828 WARNING: stderr:   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\importlib\util.py", line 88, in find_spec
     parent = __import__(parent_name, fromlist=['__path__'])
28829 WARNING: stderr:     parent = __import__(parent_name, fromlist=['__path__'])
   File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
28829 WARNING: stderr:   File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
     from . import add_newdocs
28830 WARNING: stderr:     from . import add_newdocs
   File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
28830 WARNING: stderr:   File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
     from numpy.lib import add_newdoc
28831 WARNING: stderr:     from numpy.lib import add_newdoc
   File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
28831 WARNING: stderr:   File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
     from .type_check import *
28833 WARNING: stderr:     from .type_check import *
   File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
28833 WARNING: stderr:   File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
     import numpy.core.numeric as _nx
28834 WARNING: stderr:     import numpy.core.numeric as _nx
   File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
28834 WARNING: stderr:   File "C:\Users\Luc\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
     raise ImportError(msg)
28835 WARNING: stderr:     raise ImportError(msg)
 ImportError:
28835 WARNING: stderr: ImportError:
 Importing the multiarray numpy extension module failed.  Most
28836 WARNING: stderr: Importing the multiarray numpy extension module failed.  Most
 likely you are trying to import a failed build of numpy.
28836 WARNING: stderr: likely you are trying to import a failed build of numpy.
 If you're working with a numpy git repo, try `git clean -xdf` (removes all
28836 WARNING: stderr: If you're working with a numpy git repo, try `git clean -xdf` (removes all
 files not under version control).  Otherwise reinstall numpy.
28837 WARNING: stderr: files not under version control).  Otherwise reinstall numpy.

28837 WARNING: stderr:
 Original error was: DLL load failed: The specified module could not be found.
28837 WARNING: stderr: Original error was: DLL load failed: The specified module could not be found.

28838 WARNING: stderr:

28838 WARNING: stderr:
 The above exception was the direct cause of the following exception:
28839 WARNING: stderr: The above exception was the direct cause of the following exception:

28839 WARNING: stderr:
 Traceback (most recent call last):
28839 WARNING: stderr: Traceback (most recent call last):
   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 325, in get_module_file_attribute
28840 WARNING: stderr:   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 325, in get_module_file_attribute
     loader = pkgutil.find_loader(package)
28841 WARNING: stderr:     loader = pkgutil.find_loader(package)
   File "C:\Users\Luc\Anaconda3\Lib\pkgutil.py", line 496, in find_loader
28841 WARNING: stderr:   File "C:\Users\Luc\Anaconda3\Lib\pkgutil.py", line 496, in find_loader
     raise ImportError(msg.format(fullname, type(ex), ex)) from ex
28842 WARNING: stderr:     raise ImportError(msg.format(fullname, type(ex), ex)) from ex
 ImportError: Error while finding loader for 'numpy.core' (<class 'ImportError'>:
28843 WARNING: stderr: ImportError: Error while finding loader for 'numpy.core' (<class 'ImportError'>:
 Importing the multiarray numpy extension module failed.  Most
28843 WARNING: stderr: Importing the multiarray numpy extension module failed.  Most
 likely you are trying to import a failed build of numpy.
28843 WARNING: stderr: likely you are trying to import a failed build of numpy.
 If you're working with a numpy git repo, try `git clean -xdf` (removes all
28843 WARNING: stderr: If you're working with a numpy git repo, try `git clean -xdf` (removes all
 files not under version control).  Otherwise reinstall numpy.
28844 WARNING: stderr: files not under version control).  Otherwise reinstall numpy.

28844 WARNING: stderr:
 Original error was: DLL load failed: The specified module could not be found.
28844 WARNING: stderr: Original error was: DLL load failed: The specified module could not be found.
 )
28844 WARNING: stderr: )

28845 WARNING: stderr:
 During handling of the above exception, another exception occurred:
28845 WARNING: stderr: During handling of the above exception, another exception occurred:

28846 WARNING: stderr:
 Traceback (most recent call last):
28846 WARNING: stderr: Traceback (most recent call last):
   File "C:\Users\Luc\Anaconda3\Lib\runpy.py", line 193, in _run_module_as_main
28846 WARNING: stderr:   File "C:\Users\Luc\Anaconda3\Lib\runpy.py", line 193, in _run_module_as_main
     "__main__", mod_spec)
28847 WARNING: stderr:     "__main__", mod_spec)
   File "C:\Users\Luc\Anaconda3\Lib\runpy.py", line 85, in _run_code
28847 WARNING: stderr:   File "C:\Users\Luc\Anaconda3\Lib\runpy.py", line 85, in _run_code
     exec(code, run_globals)
28847 WARNING: stderr:     exec(code, run_globals)
   File "C:\Users\Luc\PycharmProjects\GoogleCommandCenter\venv\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
28848 WARNING: stderr:   File "C:\Users\Luc\PycharmProjects\GoogleCommandCenter\venv\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\__main__.py", line 94, in run
28849 WARNING: stderr:   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\__main__.py", line 94, in run
     run_build(pyi_config, spec_file, **vars(args))
28857 WARNING: stderr:     run_build(pyi_config, spec_file, **vars(args))
   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build
28857 WARNING: stderr:   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build
     PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
28858 WARNING: stderr:     PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\building\build_main.py", line 791, in main
28858 WARNING: stderr:   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\building\build_main.py", line 791, in main
     build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
28860 WARNING: stderr:     build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\building\build_main.py", line 737, in build
28860 WARNING: stderr:   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\building\build_main.py", line 737, in build
     exec(text, spec_namespace)
28863 WARNING: stderr:     exec(text, spec_namespace)
   File "<string>", line 20, in <module>
28864 WARNING: stderr:   File "<string>", line 20, in <module>
   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\building\build_main.py", line 213, in __init__
28866 WARNING: stderr:   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\building\build_main.py", line 213, in __init__
     self.__postinit__()
28868 WARNING: stderr:     self.__postinit__()
   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\building\datastruct.py", line 161, in __postinit__
28869 WARNING: stderr:   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\building\datastruct.py", line 161, in __postinit__
     self.assemble()
28870 WARNING: stderr:     self.assemble()
   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\building\build_main.py", line 472, in assemble
28871 WARNING: stderr:   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\building\build_main.py", line 472, in assemble
     module_hook.post_graph()
28872 WARNING: stderr:     module_hook.post_graph()
   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\building\imphook.py", line 410, in post_graph
28872 WARNING: stderr:   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\building\imphook.py", line 410, in post_graph
     self._load_hook_module()
28874 WARNING: stderr:     self._load_hook_module()
   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\building\imphook.py", line 377, in _load_hook_module
28874 WARNING: stderr:   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\building\imphook.py", line 377, in _load_hook_module
     self.hook_module_name, self.hook_filename)
28875 WARNING: stderr:     self.hook_module_name, self.hook_filename)
   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\compat.py", line 744, in importlib_load_source
28875 WARNING: stderr:   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\compat.py", line 744, in importlib_load_source
     return mod_loader.load_module()
28876 WARNING: stderr:     return mod_loader.load_module()
   File "<frozen importlib._bootstrap_external>", line 399, in _check_name_wrapper
28877 WARNING: stderr:   File "<frozen importlib._bootstrap_external>", line 399, in _check_name_wrapper
   File "<frozen importlib._bootstrap_external>", line 823, in load_module
28878 WARNING: stderr:   File "<frozen importlib._bootstrap_external>", line 823, in load_module
   File "<frozen importlib._bootstrap_external>", line 682, in load_module
28880 WARNING: stderr:   File "<frozen importlib._bootstrap_external>", line 682, in load_module
   File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
28883 WARNING: stderr:   File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
   File "<frozen importlib._bootstrap>", line 684, in _load
28886 WARNING: stderr:   File "<frozen importlib._bootstrap>", line 684, in _load
   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
28891 WARNING: stderr:   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
28893 WARNING: stderr:   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
28895 WARNING: stderr:   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\hooks\hook-numpy.core.py", line 27, in <module>
28897 WARNING: stderr:   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\hooks\hook-numpy.core.py", line 27, in <module>
     pkg_base, pkg_dir = get_package_paths('numpy.core')
28898 WARNING: stderr:     pkg_base, pkg_dir = get_package_paths('numpy.core')
   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 530, in get_package_paths
28899 WARNING: stderr:   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 530, in get_package_paths
     file_attr = get_module_file_attribute(package)
28900 WARNING: stderr:     file_attr = get_module_file_attribute(package)
   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 336, in get_module_file_attribute
28902 WARNING: stderr:   File "c:\users\luc\pycharmprojects\googlecommandcenter\venv\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 336, in get_module_file_attribute
     raise ImportError
28903 WARNING: stderr:     raise ImportError
 ImportError
28903 WARNING: stderr: ImportError

所以基本上这只是一个混乱的局面,有很多东西丢失或损坏了。但万一有人需要帮助来完成这项工作,我会和大家分享我为解决这个问题所做的一切

这是我现在的规格

# -*- mode: python -*-

"""
    First of make sure that you actually import whatever you need for your 
    app
"""

import os
from os.path import join

import sqlite3
import argparse
import pdfkit
import json
import datetime

from googleapiclient.discovery import build
import httplib2
from oauth2client import client
from oauth2client import file
from oauth2client import tools

from kivy import kivy_data_dir
from kivy.deps import sdl2, glew, gstreamer
from kivy.tools.packaging import pyinstaller_hooks as hooks
from kivy.app import App
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.uix.screenmanager import Screen, NoTransition
from kivy.uix.scrollview import ScrollView
from kivy.uix.gridlayout import GridLayout
from kivy.uix.popup import Popup
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.checkbox import CheckBox

""" 
   Next make sure you have all of kivys dependencies 
"""

block_cipher = None
kivy_deps_all = hooks.get_deps_all()
kivy_factory_modules = hooks.get_factory_modules()

"""
    Then include any files that you may need for your app
"""

datas = [
    ('analyticsreporting\\analyticsreporting.dat', 'analyticsreporting'),
    ('classes\\DataManagement.py', 'classes'),
    ('classes\\GoogleAnalytics.py', 'classes'),
    ('classes\\OtherFunctions.py', 'classes'),
    ('classes\\ReportManagement.py', 'classes'),
    ('classes\\UserManagement.py', 'classes'),
    ('client_secrets\\client_secrets.json', 'client_secrets'),
    ('database\\lite.db', 'database'),
    ('screens\\ClientsScreen.py', 'screens'),
    ('screens\\HomeScreen.py', 'screens'),
    ('screens\\MyScreenManager.py', 'screens'),
    ('screens\\ScreenManagerApp.py', 'screens'),
    ('wkhtmltopdf\\wkhtmltopdf.exe', 'wkhtmltopdf')
]

# list of modules to exclude from analysis
excludes_a = ['Tkinter', '_tkinter', 'twisted', 'docutils', 'pygments']

# list of hiddenimports
hiddenimports = kivy_deps_all['hiddenimports'] + kivy_factory_modules

# binary data
sdl2_bin_tocs = [Tree(p) for p in sdl2.dep_bins]
glew_bin_tocs = [Tree(p) for p in glew.dep_bins]
gstreamer_bin_tocs = [Tree(p) for p in gstreamer.dep_bins]
bin_tocs = sdl2_bin_tocs + glew_bin_tocs + gstreamer_bin_tocs

# assets
kivy_assets_toc = Tree(kivy_data_dir, prefix=join('kivy_install', 'data'))
source_assets_toc = Tree('images', prefix='images')
assets_toc = [kivy_assets_toc, source_assets_toc]

tocs = bin_tocs + assets_toc

a = Analysis(['main.py'],
             pathex=[os.getcwd()],
             binaries=None,
             datas=datas,
             hiddenimports=hiddenimports,
             hookspath=[],
             runtime_hooks=[],
             excludes=excludes_a,
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)


pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

"""
    Put your *tocs underneath the a.data (this would go under the collect if 
    we wanted the app to be a dir and not a onefile)
"""    

exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          *tocs,
          name='Google Analytics Command Center',
          debug=False,
          strip=False,
          upx=True,
          runtime_tmpdir=None,
          console=True )
其次,确保使用相对路径在python中引入文件 如图所示

最后,如果要导入KIVY代码内部的任何内容,请确保首先将其导入KIVY代码外部,如下所示

进口

from kivy.uix.screenmanager import NoTransition
from classes.GoogleAnalytics import GoogleAnalytics
from screens.MyScreenManager import MyScreenManager
from screens.HomeScreen import HomeScreen
from screens.ClientsScreen import ClientsScreen
from classes.OtherFunctions import resource_path
奇维码

main_widget = Builder.load_string('''
#:import NoTransition kivy.uix.screenmanager.NoTransition
#:import GoogleAnalytics classes.GoogleAnalytics.GoogleAnalytics
#:import MyScreenManager screens.MyScreenManager.MyScreenManager
#:import HomeScreen screens.HomeScreen.HomeScreen
#:import ClientsScreen screens.ClientsScreen.ClientsScreen
#:import resource_path classes.OtherFunctions.resource_path
""")
此外,我还建议阅读这篇文章(这是我得到了很多上述代码)


感谢大家的帮助。

Hmm,根据您的.spec,您似乎没有从日志中看到。PyInstaller似乎使用的是标准Python安装,而不是Anaconda。通过pip安装标准Python安装的所有依赖项,它应该可以工作。请注意,如果将
spec
文件传递给
Pyinstaller
,它会忽略命令行上提供的大多数选项,包括
--onefile
。您应该对
spec
文件进行更改,然后运行
pyinstaller main.spec
。这并不能解决你的问题,但这是你正在犯的错误。
main_widget = Builder.load_string('''
#:import NoTransition kivy.uix.screenmanager.NoTransition
#:import GoogleAnalytics classes.GoogleAnalytics.GoogleAnalytics
#:import MyScreenManager screens.MyScreenManager.MyScreenManager
#:import HomeScreen screens.HomeScreen.HomeScreen
#:import ClientsScreen screens.ClientsScreen.ClientsScreen
#:import resource_path classes.OtherFunctions.resource_path
""")