Python File "scrypt\scrypt.py", line 27, in <module>AttributeError: 'NoneType' object has no attribute 'origin'
|2024. 4. 1. 22:16
Table of contents
에러
Python을 이용해서 실행파일을 만들었을 때, scrypt.py에서 에러가 발생하는 경우가 있다.
에러 로그는 아래와 같다.
참고로 실행파일을 만든 라이브러리는 Pyinstaller다.
.spec 파일에 포함되는 binaries, datas, hiddeimports 등 많은 것을 해도 해결이 되지 않았다.
대략 원인은 Python이 아닌 다른 언어를 import할 때, 이런 의존성 문제가 생기는 것 같다.
Traceback (most recent call last):
File "~~~~~~~~~~~~~~~~~.py", line 18, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "beem\__init__.py", line 2, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "beem\steem.py", line 15, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "beem\blockchaininstance.py", line 15, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "beem\storage.py", line 7, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "beemstorage\__init__.py", line 4, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "beemstorage\base.py", line 5, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "beemstorage\masterpassword.py", line 10, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "beemgraphenebase\bip38.py", line 22, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "scrypt\__init__.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "scrypt\scrypt.py", line 27, in <module>
AttributeError: 'NoneType' object has no attribute 'origin'
[22904] Failed to execute script '~~~~~~~~~~~~~~~' due to unhandled exception!
해결 방법
위에서 언급한 것처럼 별별 방법을 다 써봤으나 해결방법은 의의로 다른 부분에서 찾게 되었다.
실행파일을 만들어주는 라이브러리가 여러 개 존재하는데 그 중 cx_Freeze를 활용했다.
순서
cx_Freeze 설치
setup.py 설정
setup.py 이용해서 build
설치 명령어
pip install cx_Freeze
아래는 setup.py 예시다.
from cx_Freeze import setup, Executable
buildOptions = dict(
packages=[
'pandas',
'schedule',
'time',
'asyncio',
'datetime',
're',
'scrypt',
],
excludes = [
"tkinter",
"numpy"])
exe = [Executable('C:/Test/~~~~~~~~~~~~~~~~~~~~~py')]
setup(
name='testingName',
version='0.0.1',
author='me',
description = 'description',
options = dict(build_exe = buildOptions),
executables = exe
)
setup.py를 만들었다면, 아래와 같이 빌드하자.
Build
python setup.py build