PyQt에 firestore 연결하고 exe 파일로 만들기 (2)

Computer 비관심/PyQt5|2019. 9. 14. 01:11
반응형

파이어베이스와 PYQT의 조화는 잘 사용하지 않는지 자료가 그다지 많지 않았다.

디버깅 하는 스스로 만들어내고 PYQT와 FIREBASE에서 발생하는 버그의 해결책들을 찾는데 시간이 오래걸렸다.

 

 

PyQ에 firestore연결하고 exe 파일 만들기- 파이어스토어 파이썬에 연동하는법(1)

https://infocentre.tistory.com/45 

 

 

1. 파이인스톨러 사용

 

(1) 파이인스톨러(pyinstaller)를 사용한다. 

- 파이인스톨러의 간단한 사용 방법은 이전 글에 적어 두었다. 

https://infocentre.tistory.com/3

 

2. 디버깅 (디버깅을 쉽게 하는 방법을 모르면 개고생합니다.)

 

(1). 파일인스톨러를 사용할때 디버깅을 위해서 처음엔 -w 플레그를 붙이지 않고 실행 파일을 만든다.

-w 플래그를 붙이면 console창이 나오지 않아서 어떤 버그가 발생했는지 알기 힘들다. 이렇게 해야 하는 이유는 잘 동작하던 파이썬 큐티프로그램이 exe파일로 만들면 실행이 안되는 경우가 있기 때문이다.

 

(2)try except 구문을 잘 이용한다. 

try:
	#실행할 코드 넣기~
    
except Exception as e: 
	print(e) #에러를 표시하기 위해서
	input() #멈추게 하기 위해서

 

이 구문은 app.exec_() 이전에 써 넣어야 디버깅 화면이 꺼지지 않는다.

 

3. 이렇게 해서 디버깅을 해보면 The 'google-cloud-firestore' distribution was not found and is required by the application 라는 에러가 나온다.

 

- 파이썬 인스톨러가 구글클라우드 파이어베이스 스토어를 실행 시키지 않는것이다. 그래서 훅을 만들어준다.

\Lib\site-packages\PyInstaller\hooks 에 들어가서 hook-google.cloud.py 파일에 아래 코드를 추가해준다.

 

datas += copy_metadata('google-cloud-firestore')

 

 

4. 그리고 다시 실행해보면 잘 되거나 아니면 이런 버그가 발생한다.

Exception ignored in: 'grpc._cython.cygrpc.ssl_roots_override_callback'
E0913 23:26:43.750000000  9436 src/core/lib/security/security_connector/ssl_utils.cc:448] assertion failed: pem_root_certs != nullptr

 

이번엔 hooks폴더에  hook-grpc.py를 만들고 아래와 같은 코드를 넣는다.

 

from PyInstaller.utils.hooks import collect_data_files

datas = collect_data_files('grpc')

 

작동한다! 

 

참조: https://stackoverflow.com/questions/55848884/google-cloud-firestore-distribution-doesnt-get-added-to-pyinstaller-build

 

5. pyqt5 5.13 버전과 파이인스톨러를 같이 사용할 경우 다른 컴퓨터로 옮겼을때 작동이 안될 수 있다.

에러 - ImportError: unable to find Qt5Core.dll on PATH

- 이 경우 가장 쉬운 해결 방법은 이전 버전으로 다운그레이드 하는 것이다.

pip install pyqt5==5.12.2

 

참조 : https://stackoverflow.com/questions/56949297/how-to-fix-importerror-unable-to-find-qt5core-dll-on-path-after-pyinstaller-b

 

 

 

 

 

 

 

 

반응형

댓글()