Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pyinstaller error - AttributeError: module 'pytest' has no attribute 'freeze_includes'

I want to make my python file to exe file, though I got an error. I tapped pyinstaller -w file.py in my cmd screen, then I got an error like below.

    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'

I added import pytest in my python file, but there's no change. Please let me know about the error.

like image 996
Lesrois Avatar asked Mar 08 '23 17:03

Lesrois


1 Answers

This issue is caused by an out of date version of pytest. I was able to resolve it by using pip uninstall pytest and pip install pytest one after the other to update to the lastest version of pytest.

like image 104
Jacob Avatar answered Apr 08 '23 13:04

Jacob