Python 2.7:pyinstaller创建qt.conf文件
我正在使用以下命令创建python脚本run.py的exe文件:Python 2.7:pyinstaller创建qt.conf文件,python,qt,pyqt,exe,pyinstaller,Python,Qt,Pyqt,Exe,Pyinstaller,我正在使用以下命令创建python脚本run.py的exe文件: pyinstaller.exe --noconsole --onefile --icon=index.ico run.py # -*- coding: utf-8 -*- import PySimpleGUI27 as sg import parse2 import UserList import UserString layout = [ [sg.Text('A2L File', si
pyinstaller.exe --noconsole --onefile --icon=index.ico run.py
# -*- coding: utf-8 -*-
import PySimpleGUI27 as sg
import parse2
import UserList
import UserString
layout = [
[sg.Text('A2L File', size=(15, 1), auto_size_text=False, justification='right'),
sg.InputText('',key='_a2l_'), sg.FileBrowse(file_types=(("A2L File", "*.a2l"),))],
[sg.Text('Signals Lexicon', size=(15, 1), auto_size_text=False, justification='right'),
sg.InputText('',key='_sigLex_'), sg.FileBrowse(file_types=(("Excel File", "*.xlsx"),))],
[sg.Text('Parameters Lexicon', size=(15, 1), auto_size_text=False, justification='right'),
sg.InputText('',key='_parLex_'), sg.FileBrowse(file_types=(("Excel File", "*.xlsx"),))],
[sg.Text('Module Name', size=(15, 1), auto_size_text=False, justification='right'),
sg.InputText('X',key='_module_'), sg.FolderBrowse()],
[sg.Submit(), sg.Cancel()],
[sg.Output(size=(60, 20))]
]
window = sg.Window('A2L Parser', default_element_size=(40, 1), icon=u'C:\\Users\\anubhav.jhalani\\Desktop\\index.ico').Layout(layout)
values_dict={}
if __name__ == '__main__':
while True:
button, values_dict = window.Read()
if button=="Cancel" or 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_'],window)
else:
sg.Popup("Please select files")
window.Close()
它在dist文件夹中创建了一个exe文件,当我双击该exe文件时,它还会生成一个qt.conf文件,其内容如下:
[Paths]
Prefix = C:/Users/ANUBHA~1.JHA/AppData/Local/Temp/_MEI94~1/PyQt4
Binaries = C:/Users/ANUBHA~1.JHA/AppData/Local/Temp/_MEI94~1/PyQt4
如何停止生成此qt.conf以及为什么生成此qt.conf
信息:
我的python脚本run.py:
pyinstaller.exe --noconsole --onefile --icon=index.ico run.py
# -*- coding: utf-8 -*-
import PySimpleGUI27 as sg
import parse2
import UserList
import UserString
layout = [
[sg.Text('A2L File', size=(15, 1), auto_size_text=False, justification='right'),
sg.InputText('',key='_a2l_'), sg.FileBrowse(file_types=(("A2L File", "*.a2l"),))],
[sg.Text('Signals Lexicon', size=(15, 1), auto_size_text=False, justification='right'),
sg.InputText('',key='_sigLex_'), sg.FileBrowse(file_types=(("Excel File", "*.xlsx"),))],
[sg.Text('Parameters Lexicon', size=(15, 1), auto_size_text=False, justification='right'),
sg.InputText('',key='_parLex_'), sg.FileBrowse(file_types=(("Excel File", "*.xlsx"),))],
[sg.Text('Module Name', size=(15, 1), auto_size_text=False, justification='right'),
sg.InputText('X',key='_module_'), sg.FolderBrowse()],
[sg.Submit(), sg.Cancel()],
[sg.Output(size=(60, 20))]
]
window = sg.Window('A2L Parser', default_element_size=(40, 1), icon=u'C:\\Users\\anubhav.jhalani\\Desktop\\index.ico').Layout(layout)
values_dict={}
if __name__ == '__main__':
while True:
button, values_dict = window.Read()
if button=="Cancel" or 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_'],window)
else:
sg.Popup("Please select files")
window.Close()
pyinstaller版本:3.4似乎只有在使用常用Python或WinPython时才会创建
qt.conf
文件。出于某种原因,它似乎不是在使用Anaconda Python时创建的。在Pyinstaller源代码中对qt.conf
进行Grepping不会给出任何信息
作为一种解决方法,您可以在创建可执行文件后删除qt.conf
文件
def remove_qt_temporary_files():
if os.path.exists('qt.conf'):
os.remove('qt.conf')
不删除
删除
例如。我不能100%确定qt.conf文件是在哪里创建的,但是在最后删除该文件似乎是可行的
from PyQt4 import QtCore, QtGui
import sys
import os
def remove_qt_temporary_files():
if os.path.exists('qt.conf'):
os.remove('qt.conf')
class ButtonGrid(QtGui.QWidget):
def __init__(self, parent=None):
super(ButtonGrid, self).__init__(parent)
self.button_layout = QtGui.QGridLayout()
for i in range(1,5):
for j in range(1,5):
self.button_layout.addWidget(QtGui.QPushButton("B"+str(i)+str(j)),i,j)
def get_layout(self):
return self.button_layout
if __name__ == '__main__':
# Create main application window
app = QtGui.QApplication([])
app.setStyle(QtGui.QStyleFactory.create("Cleanlooks"))
mw = QtGui.QMainWindow()
mw.setWindowTitle('Remove qt.conf example')
# Create button grid widget
button_grid = ButtonGrid()
# Create and set widget layout
# Main widget container
cw = QtGui.QWidget()
ml = QtGui.QGridLayout()
cw.setLayout(ml)
mw.setCentralWidget(cw)
ml.addLayout(button_grid.get_layout(),0,0)
mw.show()
remove_qt_temporary_files()
if(sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()
你到底把这个代码放在哪里?因为双击exe文件后会生成qt.conf