pyinstaller によるexe化のエラーメッセージと対処方法

# はじめに：PyInstallerによるexe化
- python 3.7で作成したモジュールをpythonと導入していない他の端末で使用するために、exe化をしたかった
- 端末状況：
    - OS: Windows 7
    - python: 3.7
    - PyInstaller: 3.4

# exe化のための実行コマンド
- コマンドプロンプトで実行
    - 1回目：```python3 -m PyInstaller ***.py --onefile --clean```
    - 2回目(エラー1対応後)：```python3 -m PyInstaller ***.spec --onefile --clean```
    - 変更点：***.py ⇒ ***.spec

# エラー1：RecursionError: maximum recursion depth exceeded while calling a Python object
- 対処方法：コマンド実行後に作成される***.specファイル上で下記を追加。
- [「Anaconda環境で作成したPythonプログラムをexe化した話。」](https://qiita.com/shikasama/items/d0418fa4a604cfc00337) を参考

```python
import sys
sys.setrecursionlimit(5000)
```

# エラー2：WARNING: Cannot read QLibraryInfo output: raised Expecting value: line 1 column 1 (char 0) when decoding:
- 対応方法：PyInstallerのqt.pyのjson_str部分を変更 (...\PyInstaller\utils\hooks\qt.py)
    - 手順１：QLibraryInfoの必要な情報を取得
    - 手順2: qt.py のjson_str箇所を以下に変更（以下は例のため、各端末によって異なります）
- [PyQt5 Cannot read QLibraryInfo output: raised Expecting value: line 1 column 1 (char 0) when decoding #3971](https://github.com/pyinstaller/pyinstaller/issues/3971)を参考

```python:手順1
import json
from PyQt5.QtCore import QLibraryInfo

#必要な情報は、'isDebugBuild', 'version', 'location'
isDebugBuild = QLibraryInfo.isDebugBuild()
version = QLibraryInfo.version().segments)
paths = [x for x in dir(QLibraryInfo) if x.endswith('Path')]
location = {x: QLibraryInfo.location(getattr(QLibraryInfo, x)) for x in paths}
```

```python:手順2
json_str = '{"isDebugBuild": isDebugBuildの結果(True または False), 
"version":[5,12,3], 
"location":{"ArchDataPath": "/usr/local/lib/python3.5/dist-packages/PyQt5/Qt",
"LibraryExecutablesPath": "/usr/local/lib/python3.5/dist-packages/PyQt5/Qt/libexec",
 "Qml2ImportsPath": "/usr/local/lib/python3.5/dist-packages/PyQt5/Qt/qml", 
"ExamplesPath": "/usr/local/lib/python3.5/dist-packages/PyQt5/Qt/examples",
 "DocumentationPath": "/usr/local/lib/python3.5/dist-packages/PyQt5/Qt/doc",
 "PluginsPath": "/usr/local/lib/python3.5/dist-packages/PyQt5/Qt/plugins",
 "LibrariesPath": "/usr/local/lib/python3.5/dist-packages/PyQt5/Qt/lib",
 "ImportsPath": "/usr/local/lib/python3.5/dist-packages/PyQt5/Qt/imports",
 "HeadersPath": "/usr/local/lib/python3.5/dist-packages/PyQt5/Qt/include",
 "TranslationsPath": "/usr/local/lib/python3.5/dist-packages/PyQt5/Qt/translations", "SettingsPath": "/usr/local/lib/python3.5/dist-packages/PyQt5/Qt",
 "PrefixPath": "/usr/local/lib/python3.5/dist-packages/PyQt5/Qt",
 "DataPath": "/usr/local/lib/python3.5/dist-packages/PyQt5/Qt",
 "TestsPath": "/usr/local/lib/python3.5/dist-packages/PyQt5/Qt/tests",
 "BinariesPath": "/usr/local/lib/python3.5/dist-packages/PyQt5/Qt/bin"}}'
```


- エラー全体（以下）

```python
68440 WARNING: Cannot read QLibraryInfo output: raised Expecting value: line 1 c
olumn 1 (char 0) when decoding:
Traceback (most recent call last):
  File "<string>", line 11, in <module>
ImportError: DLL load failed: 指定されたプロシージャが見つかりません。
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec)
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\__main__.py", line 118, in <module>run()
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 838, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 784, in build
    exec(text, spec_namespace)
  File "<string>", line 19, in <module>
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 241, in __init__
    self.__postinit__()
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
    self.assemble()
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 500, in assemble
    module_hook.post_graph()
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\building\imphook.py", line 410, in post_graph
    self._load_hook_module()
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\building\imphook.py", line 377, in _load_hook_module
    self.hook_module_name, self.hook_filename)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\compat.py", line 736, in importlib_load_source
    return mod_loader.load_module()
  File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 907, in load_module
  File "<frozen importlib._bootstrap_external>", line 732, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\hooks\hook-PyQt5.py", line 23, in <module>
    collect_system_data_files(pyqt5_library_info.location['PrefixPath'],
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 71, in __getattr__
    qli = json.loads(json_str)
  File "C:\ProgramData\Anaconda3\lib\json\__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
```
# エラー3:UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 130: invalid start byte

- [pythonスクリプトをexeに変換する（つまづきポイントまとめ）](https://qiita.com/pocket_kyoto/items/80a1ac0e46819d90737f#%E3%81%9D%E3%81%AE%EF%BC%93unicodedecodeerror-utf-8-codec-cant-decode-byte-0x83-in-position-130-invalid-start-byte) に丁寧に書いてあるので参照