【问题标题】:pyinstaller error - AttributeError: module 'pytest' has no attribute 'freeze_includes'pyinstaller 错误 - AttributeError:模块“pytest”没有属性“freeze_includes”
【发布时间】:2019-07-23 22:51:08
【问题描述】:

我想将我的 python 文件转换为 exe 文件,但我遇到了一个错误。 我在我的 cmd 屏幕中点击了pyinstaller -w file.py, 然后我收到如下错误。

    Traceback (most recent call last):
  File "C:\Python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python36\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
  File "C:\Python36\lib\site-packages\PyInstaller\__main__.py", line 92, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Python36\lib\site-packages\PyInstaller\__main__.py", line 46, in run_
build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Python36\lib\site-packages\PyInstaller\building\build_main.py", line
791, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'
))
  File "C:\Python36\lib\site-packages\PyInstaller\building\build_main.py", line
737, in build
    exec(text, spec_namespace)
  File "<string>", line 16, in <module>
  File "C:\Python36\lib\site-packages\PyInstaller\building\build_main.py", line
213, in __init__
    self.__postinit__()
  File "C:\Python36\lib\site-packages\PyInstaller\building\datastruct.py", line
161, in __postinit__
    self.assemble()
  File "C:\Python36\lib\site-packages\PyInstaller\building\build_main.py", line
472, in assemble
    module_hook.post_graph()
  File "C:\Python36\lib\site-packages\PyInstaller\building\imphook.py", line 410
, in post_graph
    self._load_hook_module()
  File "C:\Python36\lib\site-packages\PyInstaller\building\imphook.py", line 377
, in _load_hook_module
    self.hook_module_name, self.hook_filename)
  File "C:\Python36\lib\site-packages\PyInstaller\compat.py", line 728, in impor
tlib_load_source
    return mod_loader.load_module()
  File "<frozen importlib._bootstrap_external>", line 399, in _check_name_wrappe
r
  File "<frozen importlib._bootstrap_external>", line 823, in load_module
  File "<frozen importlib._bootstrap_external>", line 682, in load_module
  File "<frozen importlib._bootstrap>", line 251, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 675, in _load
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "C:\Python36\lib\site-packages\PyInstaller\hooks\hook-pytest.py", line 16
, in <module>
    hiddenimports = pytest.freeze_includes()
AttributeError: module 'pytest' has no attribute 'freeze_includes'

我在我的 python 文件中添加了import pytest,但没有任何变化。 请让我知道错误。

【问题讨论】:

  • 你能在 python shell 终端\命令提示符下尝试'import pytest` 后跟pytest.freeze_includes() 吗?

标签: python pyinstaller


【解决方案1】:

这个问题是由过期版本的 pytest 引起的。我能够通过使用pip uninstall pytestpip install pytest一个接一个地更新到最新版本的pytest来解决它。

【讨论】:

    【解决方案2】:

    就我而言,Jacob 提出的更新并没有真正帮助,因为违反了其他要求。我的程序中不需要 pytest,所以我只是从 PyInstaller 中删除了 pytest 钩子。我的道路是

    C:\Python37-32\Lib\site-packages\PyInstaller\hooks\hook-pytest.py
    

    所以不是真正的“解决方案”,但仍然对我有用。

    【讨论】:

      猜你喜欢
      • 2023-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 1970-01-01
      • 2019-04-10
      相关资源
      最近更新 更多