pyinstaller를 사용하여 데이터 파일 (png 파일 및 pot 파일)을로드해야하는 응용 프로그램에서 작업 중이며 temp 폴더의 파일을 추적 중이므로 데이터 파일이 추가되지 않습니다. 어떤 이유로 임시 폴더.pyinstaller2.0을 사용하여 데이터 파일로드
:a = Analysis(['mks_controller.py'],
pathex=['C:\\pyinstaller-2.0\\pyinstaller-2.0'],
hiddenimports=[],
hookspath=None)
a.datas += [('presentation.potx','C:\\pyinstaller-2.0\\pyinstaller-2.0\\bbpresentation.potx','DATA'),('splat.png','C:\\pyinstaller-2.0\\pyinstaller-2.0\\splat.png', 'DATA'),('logo.png','C:\\pyinstaller-2.0\\pyinstaller-2.0\\logo.png','DATA')]
pyz = PYZ(a.pure)
나는 다음과 같은 두 가지 명령을 사용하여 EXE를 구축 : 나는 또한 사양 파일을 수정
import os, sys
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
: 나는 다음과 같다 디렉토리를 추적하는 작은 모듈을 만든
pyinstaller.py --onefile filename.py
pyinstaller.py --onefile filename.spec
이고 데이터 파일이 디렉토리에로드되지 않습니다. 또한이 디렉토리에있는 모든 파일을 보여주는 로그를 실행하려고 시도했지만 데이터 파일은 표시되지 않습니다.
http://imgur.com/delete/qIff0zZT2Y4ZdKT
나는 파이썬 2.7과 2.0 pyInstaller 중에을 사용하고 있습니다 : 여기의 스크린 샷이다. 문제가 무엇인지 누구나 알고 있습니까? 미리 감사드립니다!
--onefile을 수행하고 --onefile; 이외의 것을 얻지는 않는다고 생각합니다. 수동으로 같은 위치에 리소스를 넣고 아마도 우편이나 뭔가를 만들면됩니다. (틀릴 수도 있습니다.) .) –