将 python 文件转换为可执行文件时出现 Pyinstaller 脚本错误

Pyinstaller script error when converting a python file into an executable

我正在尝试使用 pyinstaller 将我的 python 文件转换为可执行文件,但我一直收到此错误。

Traceback (most recent call last):
  File "sr_gui_test.py", line 12, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 540, in exec_module
  File "requests_html.py", line 9, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 540, in exec_module
  File "pyppeteer\__init__.py", line 43, in <module>
NameError: name '__version__' is not defined

我不知道这个 version 变量是什么以及我应该如何解决这个问题。

pyppeteer issue #213 有一个解决方法:按照 nowind 的建议编辑 __init__.py

pyppeteer/__init__.py 中,只需添加行

__version__="0.2.5"

行后:

try:
    __version__ = version(__name__)
except Exception:
    pass