Python pyinstaller错误-AttributeError:模块';pytest';没有属性';冻结包括';

Python pyinstaller错误-AttributeError:模块';pytest';没有属性';冻结包括';,python,pyinstaller,Python,Pyinstaller,我想将我的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", l

我想将我的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'
回溯(最近一次呼叫最后一次):
文件“C:\Python36\lib\runpy.py”,第193行,在运行模块中作为主
“\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
文件“C:\Python36\lib\runpy.py”,第85行,在运行代码中
exec(代码、运行\全局)
文件“C:\Python36\Scripts\pyinstaller.exe\\uuuuu main\uuuuuu.py”,第9行,在
文件“C:\Python36\lib\site packages\PyInstaller\\uuuuu main\uuuuuu.py”,第92行,正在运行
运行构建(pyi\u配置,规范文件,**vars(args))
文件“C:\Python36\lib\site packages\PyInstaller\\uuuuu main\uuuuuu.py”,第46行,正在运行_
建造
PyInstaller.building.build\u main.main(pyi\u配置,spec\u文件,**kwargs)
文件“C:\Python36\lib\site packages\PyInstaller\building\build\u main.py”,第行
791,总的来说
构建(specfile,kw.get('distpath')、kw.get('workpath')、kw.get('clean_build'
))
文件“C:\Python36\lib\site packages\PyInstaller\building\build\u main.py”,第行
737,在建
exec(文本,规范名称空间)
文件“”,第16行,在
文件“C:\Python36\lib\site packages\PyInstaller\building\build\u main.py”,第行
213,在初始__
self.\uuuu postinit\uuuuu()
文件“C:\Python36\lib\site packages\PyInstaller\building\datastruct.py”,第行
161,在邮政局__
self.assembly()
文件“C:\Python36\lib\site packages\PyInstaller\building\build\u main.py”,第行
472,在组装中
模块\u hook.post\u图()
文件“C:\Python36\lib\site packages\PyInstaller\building\imphook.py”,第410行
,在post_图中
自。\加载\挂钩\模块()
文件“C:\Python36\lib\site packages\PyInstaller\building\imphook.py”,第377行
,在“装载”模块中
self.hook\u模块名称、self.hook\u文件名)
文件“C:\Python36\lib\site packages\PyInstaller\compat.py”,第728行,在import中
tlib_加载_源
返回mod_loader.load_模块()
文件“”,第399行,在\u check\u name\u wrappe中
R
加载模块中第823行的文件“”
加载模块中第682行的文件“”
文件“”,第251行,在加载模块垫片中
文件“”,第675行,正在加载
文件“”,第655行,已加载
exec_模块中第678行的文件“”
文件“”,第205行,在调用中删除了帧
文件“C:\Python36\lib\site packages\PyInstaller\hooks\hook pytest.py”,第16行
在里面
hiddenimports=pytest.freeze_includes()
AttributeError:模块“pytest”没有“冻结”属性
我在python文件中添加了
import-pytest
,但没有任何更改。
请让我知道错误。

此问题是由pytest的过期版本引起的。我可以通过依次使用
pip uninstall pytest
pip install pytest
更新到pytest的最新版本来解决这个问题。

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

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

因此,这不是一个真正的“解决方案”,但对我来说仍然有效。

您能在python shell终端\命令提示符中尝试“导入pytest”,然后是
pytest.freeze\u includes()