Python 3.7:使用pyinstaller创建exe文件时出错

时间:2019-06-03 14:13:31

标签: python python-3.x runtime-error exe pyinstaller

下面是我要转换为exe文件的GUI的python文件run.py:

# -*- coding: utf-8 -*-
import PySimpleGUIQt as sg
import parse2

layout = [               
    [sg.Checkbox('Module Selection', default=False, change_submits = True, key='_checkbox_' )],
    [sg.Text('A2L File', size=(13,0.5), auto_size_text=True, justification='right'),      
     sg.InputText('',key='_a2l_'), sg.FileBrowse(file_types=(("A2L File", "*.a2l"),), auto_size_button=False)],
    [sg.Text('Signals Lexicon', size=(13,0.5), auto_size_text=True, justification='right', key='_sigLextext_'),      
     sg.InputText('',key='_sigLex_'), sg.FileBrowse(file_types=(("Excel File", "*.xlsx"),),key='_sigLexbutton_', auto_size_button=False)],
    [sg.Text('Parameters Lexicon', size=(13,0.5), auto_size_text=True, justification='right', key='_parLextext_'),      
     sg.InputText('',key='_parLex_'), sg.FileBrowse(file_types=(("Excel File", "*.xlsx"),),key='_parLexbutton_', auto_size_button=False)],
    [sg.Text('Module', size=(13,0.5), auto_size_text=True, justification='right',key='_moduletext_'),      
     sg.InputText('',key='_module_'), sg.FileBrowse(key='_modulebutton_', auto_size_button=False)],
    [sg.Text('Save Reports at', size=(13,0.5), auto_size_text=True, justification='right'),      
     sg.InputText('',key='_reports_'), sg.FolderBrowse(auto_size_button=False)],            
    [sg.Submit(auto_size_button=False)],
    [sg.Output(size=(540 , 340))]  
]


window = sg.Window('A2L Parser', icon=u'C:\\Users\\anubhav.jhalani\\Documents\\A2L Parser\\A2L parser_09_05\\A2L parser\\index.ico').Layout(layout).Finalize()
values_dict={}

while True:  # Event Loop
    window.Enable()            
    button, values_dict = window.Read()    

    if button is None:
        break
    elif button=='Submit' and (not any(value == '' for value in values_dict.values())):   
        parse2.parser(values_dict['_a2l_'], values_dict['_sigLex_'], values_dict['_parLex_'], values_dict['_module_'],  values_dict['_reports_'], values_dict['_checkbox_'], window)        
    elif button=='Submit' and (any(value == '' for value in values_dict.values())):
        window.Disable()
        sg.Popup("Please select files", no_titlebar=True, keep_on_top=True)


window.Close()

我使用以下命令将文件转换为.exe文件:

C:\Python37\Scripts\pyinstaller --noconsole --icon=index.ico --onedir run.py    

但是我得到以下错误:

15189 INFO: Processing pre-safe import module hook   setuptools.extern.six.moves
Traceback (most recent call last):
  File "c:\program files\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python37\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
  File "c:\program files\python37\lib\site-packages\PyInstaller\__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\program files\python37\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\program files\python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1422, in import_hook
    target_module = self._load_tail(target_package, target_module_partname)
 .
 .
 .
 .
  File "c:\program files\python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1635, in _load_tail
    submodule = self._safe_import_module(head, mname, submodule)
  File "c:\program files\python37\lib\site-packages\PyInstaller\depend\analysis.py", line 260, in _safe_import_module
    hook_module.pre_safe_import_module(hook_api)
  File "c:\program files\python37\lib\site-packages\PyInstaller\hooks\pre_safe_import_module\hook-setuptools.extern.six.moves.py", line 34, in pre_safe_import_module
    for real_module_name, six_module_name in real_to_six_module_name.items():
AttributeError: 'str' object has no attribute 'items'

我尝试按照不同论坛上的建议更新setuptools,但错误仍然相同。有趣的是,当pyinstaller命令运行时,我的GUI会自动显示在屏幕上,我必须手动将其关闭。我过去已经使用pyinstaller很多次了,但是这个问题对我来说是全新的。有人可以建议我在做什么错吗?

更新:我刚刚通过以下命令纠正了错误:pip install --force-reinstall --no-binary :all: pyinstaller。在这里找到它:github.com/pyinstaller/pyinstaller/issues/3777

0 个答案:

没有答案
相关问题