pyqt4를 사용하고 있습니다. 아이콘이 추가되었습니다.pyqt4 py2exe 아이콘 추가
basis = sys.argv[0]
required_folder = os.path.split(basis)[0]
# print required_folder
imagepath = required_folder + '\mark.JPG'
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8(imagepath)), QtGui.QIcon.Normal, QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)
py2exe의 setup.py에서 자원에 아이콘을 추가하려고합니다.
#setup.py
from distutils.core import setup
import py2exe
setup(
windows=[{"script": "MainFile.py"}],
options={
"py2exe":
{
"dll_excludes" : ["MSVCP90.dll"],
"includes": ['encodings', 'encodings.*']
}
}
)
python 스크립트로 프로그램을 시작할 때 내 아이콘이 보입니다. py2exe로 exe 프로그램을 만들면 프로그램이 제대로 작동하지만 아이콘이 사라집니다.
========================== ===========================
나는 이미 그것을 해결했습니다. 그래서, 여기에 내 코드가있다.
py2exe에 가져 오지 않습니다. 가져올 수없는 이유는 무엇입니까?
============================================== ================= 코드를 변경했습니다. 내가 cmd에 py2exe를 실행할 때. "예기치 않은 종료 오류" * 데이터 파일 복사 * < - 실행이 중지되었습니다.
setup(
windows=[{"script": "2017_12_01.py", "icon_resources": [(1, "mark.jpg")]}],
data_files = [('imageformats', [r'C:\Python27\Lib\site-packages\PyQt4\plugins\imageformats\qjpeg4.dll'])],
options={
"py2exe":
{
"dll_excludes" : ["MSVCP90.dll"],
"includes": ['encodings', 'encodings.*', "sip"]
}
},
)
좋아, 난 정말 노력했다. Py2exe는 초보자에게 가장 쉽지 않으며 문제 발생 후 문제가 발생합니다. 시도해보십시오 : PyInstaller. 'py install pyinstaller' 그리고 나서'pyinstaller path/to/your/file.py -i path/to/your/icon.ico'을 실행하고 완료하십시오. – Pat
또는, 만약 당신이 붙들고 싶다면 http://www.py2exe.org/index.cgi/Tutorial#Step52 – Pat
슬프게도 pyinstaller가 작동하지 않습니다. py2exe에 대해 한 번 더 확인하십시오. 코드를 변경했습니다. – Layla