Skip to content

PyInstaller 3.6 AssertionError #4626

Closed

Description

@arossert

Hi, since the latest 3.6 release all my Linux builds are failing with a new AssertionError.
This is the log:

23 INFO: PyInstaller: 3.6
24 INFO: Python: 2.7.16
25 INFO: Platform: Linux-4.9.184-linuxkit-x86_64-with-debian-squeeze-sid
26 INFO: wrote /simulator.spec
35 INFO: UPX is not available.
36 INFO: Removing temporary files and cleaning cache in /.cache/pyinstaller
37 INFO: Extending PYTHONPATH with paths
['/agent/project/src/bin', '/']
37 INFO: checking Analysis
37 INFO: Building Analysis because Analysis-00.toc is non existent
38 INFO: Initializing module dependency graph...
49 INFO: Caching module graph hooks...
Traceback (most recent call last):
  File "/usr/local/bin/pyinstaller", line 8, in <module>
    sys.exit(run())
  File "/usr/local/lib/python2.7/site-packages/PyInstaller/__main__.py", line 114, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "/usr/local/lib/python2.7/site-packages/PyInstaller/__main__.py", line 65, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/PyInstaller/building/build_main.py", line 734, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "/usr/local/lib/python2.7/site-packages/PyInstaller/building/build_main.py", line 681, in build
    exec(code, spec_namespace)
  File "/simulator.spec", line 17, in <module>
    noarchive=False)
  File "/usr/local/lib/python2.7/site-packages/PyInstaller/building/build_main.py", line 244, in __init__
    self.__postinit__()
  File "/usr/local/lib/python2.7/site-packages/PyInstaller/building/datastruct.py", line 160, in __postinit__
    self.assemble()
  File "/usr/local/lib/python2.7/site-packages/PyInstaller/building/build_main.py", line 343, in assemble
    excludes=self.excludes, user_hook_dirs=self.hookspath)
  File "/usr/local/lib/python2.7/site-packages/PyInstaller/depend/analysis.py", line 734, in initialize_modgraph
    user_hook_dirs=user_hook_dirs,
  File "/usr/local/lib/python2.7/site-packages/PyInstaller/depend/analysis.py", line 116, in __init__
    self._reset(user_hook_dirs)
  File "/usr/local/lib/python2.7/site-packages/PyInstaller/depend/analysis.py", line 134, in _reset
    self._hooks = self._cache_hooks("")
  File "/usr/local/lib/python2.7/site-packages/PyInstaller/depend/analysis.py", line 215, in _cache_hooks
    return ModuleHookCache(self, hook_dirs)
  File "/usr/local/lib/python2.7/site-packages/PyInstaller/depend/imphook.py", line 100, in __init__
    self._cache_hook_dirs(hook_dirs)
  File "/usr/local/lib/python2.7/site-packages/PyInstaller/depend/imphook.py", line 133, in _cache_hook_dirs
    hook_module_name_prefix=self._hook_module_name_prefix,
  File "/usr/local/lib/python2.7/site-packages/PyInstaller/depend/imphook.py", line 289, in __init__
    assert self.hook_module_name not in HOOKS_MODULE_NAMES
AssertionError

PyInstaller: 3.6
OS: Linux & macOS
Python: 2.7

After reverting to version 3.5 it seems to work fine, what can I do to try to find the source of this issue?

Activity

  1. AndCycle commented on Jan 13, 2020

    @AndCycle
    Contributor

    did simple test shows it died on my custom gevent hook,
    remove custom hook pleased PyInstaller.

    maybe you can share what died on your setup?

    self.hook_module_name value is __PyInstaller_hooks_0_gevent

    mine hook-gevent.py

    # -*- coding: utf-8 -*-
    
    hiddenimports = [
            'gevent.__greenlet_primitives',
            'gevent.__hub_local',
            'gevent.__hub_primitives',
            'gevent.__ident',
            'gevent.__imap',
            'gevent.__semaphore',
            'gevent.__tracer',
            'gevent.__waiter',
            'gevent._event',
            'gevent._greenlet',
            'gevent._local',
            'gevent._queue',
    
            # info from monkey patch_all
            'gevent.os',
            'gevent.time',
            'gevent.thread',
            # 'gevent.sys',
            'gevent.socket',
            'gevent.select',
            'gevent.ssl',
            # 'gevent.httplib',
            'gevent.subprocess',
            'gevent.builtins',
            'gevent.signal',
    
            'gevent.libev',
            'gevent.libev.corecext',
            'gevent.libev.corecffi',
            'gevent.libev.watcher',
    
            'gevent.libuv',
            'gevent.libuv._corecffi',
            'gevent.libuv.loop',
            'gevent.libuv.watcher',
        ]
    
    (venv37) D:\AndCycle\Documents\work\corelight\proj\sview-agent>pyinstaller --clean --noupx --version-file=tmp\build_dist_ver.txt --additional-hooks-dir=. --add-data bin;bin --onefile ykaccess.py
    84 INFO: PyInstaller: 3.6
    84 INFO: Python: 3.7.4
    84 INFO: Platform: Windows-10-10.0.18362-SP0
    84 INFO: wrote D:\AndCycle\Documents\work\corelight\proj\sview-agent\ykaccess.spec
    100 INFO: UPX is not available.
    100 INFO: Removing temporary files and cleaning cache in C:\Users\AndCycle\AppData\Roaming\pyinstaller
    100 INFO: Extending PYTHONPATH with paths
    ['D:\\AndCycle\\Documents\\work\\corelight\\proj\\sview-agent',
     'D:\\AndCycle\\Documents\\work\\corelight\\proj\\sview-agent']
    100 INFO: checking Analysis
    100 INFO: Building Analysis because Analysis-00.toc is non existent
    100 INFO: Initializing module dependency graph...
    100 INFO: Caching module graph hooks...
    Traceback (most recent call last):
      File "C:\Python37\lib\runpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "C:\Python37\lib\runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "D:\AndCycle\Documents\work\corelight\proj\sview-agent\venv37\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
      File "d:\andcycle\documents\work\corelight\proj\sview-agent\venv37\lib\site-packages\PyInstaller\__main__.py", line 114, in run
        run_build(pyi_config, spec_file, **vars(args))
      File "d:\andcycle\documents\work\corelight\proj\sview-agent\venv37\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
        PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
      File "d:\andcycle\documents\work\corelight\proj\sview-agent\venv37\lib\site-packages\PyInstaller\building\build_main.py", line 734, in main
        build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
      File "d:\andcycle\documents\work\corelight\proj\sview-agent\venv37\lib\site-packages\PyInstaller\building\build_main.py", line 681, in build
        exec(code, spec_namespace)
      File "D:\AndCycle\Documents\work\corelight\proj\sview-agent\ykaccess.spec", line 17, in <module>
        noarchive=False)
      File "d:\andcycle\documents\work\corelight\proj\sview-agent\venv37\lib\site-packages\PyInstaller\building\build_main.py", line 244, in __init__
        self.__postinit__()
      File "d:\andcycle\documents\work\corelight\proj\sview-agent\venv37\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
        self.assemble()
      File "d:\andcycle\documents\work\corelight\proj\sview-agent\venv37\lib\site-packages\PyInstaller\building\build_main.py", line 343, in assemble
        excludes=self.excludes, user_hook_dirs=self.hookspath)
      File "d:\andcycle\documents\work\corelight\proj\sview-agent\venv37\lib\site-packages\PyInstaller\depend\analysis.py", line 734, in initialize_modgraph
        user_hook_dirs=user_hook_dirs,
      File "d:\andcycle\documents\work\corelight\proj\sview-agent\venv37\lib\site-packages\PyInstaller\depend\analysis.py", line 116, in __init__
        self._reset(user_hook_dirs)
      File "d:\andcycle\documents\work\corelight\proj\sview-agent\venv37\lib\site-packages\PyInstaller\depend\analysis.py", line 134, in _reset
        self._hooks = self._cache_hooks("")
      File "d:\andcycle\documents\work\corelight\proj\sview-agent\venv37\lib\site-packages\PyInstaller\depend\analysis.py", line 215, in _cache_hooks
        return ModuleHookCache(self, hook_dirs)
      File "d:\andcycle\documents\work\corelight\proj\sview-agent\venv37\lib\site-packages\PyInstaller\depend\imphook.py", line 100, in __init__
        self._cache_hook_dirs(hook_dirs)
      File "d:\andcycle\documents\work\corelight\proj\sview-agent\venv37\lib\site-packages\PyInstaller\depend\imphook.py", line 133, in _cache_hook_dirs
        hook_module_name_prefix=self._hook_module_name_prefix,
      File "d:\andcycle\documents\work\corelight\proj\sview-agent\venv37\lib\site-packages\PyInstaller\depend\imphook.py", line 289, in __init__
        assert self.hook_module_name not in HOOKS_MODULE_NAMES
    AssertionError
    
    

    and this is not the only place that failed, still digging.

  2. htgoebel commented on Jan 17, 2020

    @htgoebel
    Member

    @AndCycle Since you already have a clue and an environment which triggers this isse: Please track sit down, and send me an email afterwards. Many thanks.

  3. AndCycle commented on Jan 17, 2020

    @AndCycle
    Contributor

    @htgoebel
    04d63e1

    the safety check triggered when there is a custom hook conflict with builtin one.
    an empty hook file can trigger it.

  4. arossert commented on Jan 19, 2020

    @arossert
    ContributorAuthor

    @AndCycle Thanks for the investigation, it was indeed a hook that I had in my code and the same hook was represented in the new version (from my PR 😃).
    Even when the hooks are exactly the same it is failing.

  5. robertobrien130 commented on Jan 19, 2020

    @robertobrien130

    I was also getting this error, but after I rolled back to 3.5, I started getting this error when I launched my --windowed app:

    Screen Shot 2020-01-19 at 3 34 07 PM

    I wasn't getting this error before the upgrade to 3.6. If I build the app without the --windowed option, the app crashes and closes the command window before I can copy the traceback error.

    Using Windows 10, Python 3.7.6.

    Any help you guys can give?

  6. matham commented on Jan 19, 2020

    @matham
    Contributor

    I was also getting this error, but after I rolled back to 3.5, I started getting this error

    Please open another issue for this, as it's off-topic of this issue.

    the app crashes and closes the command window before I can copy the traceback error.

    Try running the app from an existing cmd terminal, then the traceback will remain written on that terminal.

  7. DarkFenX commented on Jan 20, 2020

    @DarkFenX

    I have the same issue.

    Windows 8.1 Pro 64 bit
    Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 23 2018, 23:31:17) [MSC v.1916 32 bit (Intel)] on win32
    
    Traceback (most recent call last):
      File "C:\Python36_x86\lib\runpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "C:\Python36_x86\lib\runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "C:\Python36_x86\lib\site-packages\PyInstaller\__main__.py", line 121, in
     <module>
        run()
      File "C:\Python36_x86\lib\site-packages\PyInstaller\__main__.py", line 114, in
     run
        run_build(pyi_config, spec_file, **vars(args))
      File "C:\Python36_x86\lib\site-packages\PyInstaller\__main__.py", line 65, in
    run_build
        PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
      File "C:\Python36_x86\lib\site-packages\PyInstaller\building\build_main.py", l
    ine 734, in main
        build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'
    ))
      File "C:\Python36_x86\lib\site-packages\PyInstaller\building\build_main.py", l
    ine 681, in build
        exec(code, spec_namespace)
      File "pyfa.spec", line 78, in <module>
        cipher=block_cipher)
      File "C:\Python36_x86\lib\site-packages\PyInstaller\building\build_main.py", l
    ine 244, in __init__
        self.__postinit__()
      File "C:\Python36_x86\lib\site-packages\PyInstaller\building\datastruct.py", l
    ine 160, in __postinit__
        self.assemble()
      File "C:\Python36_x86\lib\site-packages\PyInstaller\building\build_main.py", l
    ine 343, in assemble
        excludes=self.excludes, user_hook_dirs=self.hookspath)
      File "C:\Python36_x86\lib\site-packages\PyInstaller\depend\analysis.py", line
    734, in initialize_modgraph
        user_hook_dirs=user_hook_dirs,
      File "C:\Python36_x86\lib\site-packages\PyInstaller\depend\analysis.py", line
    116, in __init__
        self._reset(user_hook_dirs)
      File "C:\Python36_x86\lib\site-packages\PyInstaller\depend\analysis.py", line
    134, in _reset
        self._hooks = self._cache_hooks("")
      File "C:\Python36_x86\lib\site-packages\PyInstaller\depend\analysis.py", line
    215, in _cache_hooks
        return ModuleHookCache(self, hook_dirs)
      File "C:\Python36_x86\lib\site-packages\PyInstaller\depend\imphook.py", line 1
    00, in __init__
        self._cache_hook_dirs(hook_dirs)
      File "C:\Python36_x86\lib\site-packages\PyInstaller\depend\imphook.py", line 1
    33, in _cache_hook_dirs
        hook_module_name_prefix=self._hook_module_name_prefix,
      File "C:\Python36_x86\lib\site-packages\PyInstaller\depend\imphook.py", line 2
    90, in __init__
        assert self.hook_module_name not in HOOKS_MODULE_NAMES
    AssertionError
    

    Pyinstaller fails on __PyInstaller_hooks_0_matplotlib_backends (verified by printing before the assertion).

    Edit:
    As comment above mentioned a conflict between hooks, i checked configuration:

                 hookspath=['dist_assets/pyinstaller_hooks'],
    

    I had custom hook for matplotlib there indeed, so I just removed it to give it a try, and so far it works.

  8. Legorooj commented on Jan 22, 2020

    @Legorooj
    Member

    @robertobrien130 run the exe from the command prompt (built without the windowed command).

  9. Legorooj commented on Jan 22, 2020

    @Legorooj
    Member

    @DarkFenX So you're saying its fixed when you remove the hookspath line from the spec?

  10. DarkFenX commented on Jan 22, 2020

    @DarkFenX

    @Legorooj I did not remove hookspath specification. I just removed offending file (had matplotlib hooks file in the specified path).

  11. Legorooj commented on Jan 22, 2020

    @Legorooj
    Member

    @DarkFenX Ah. These were custom hooks I'm assuming? I know that PyInstaller has hooks included already for matplotlib, although there is one bug for matplotlib=<3.1.

  12. 10 remaining items

  13. Legorooj commented on Feb 15, 2020

    @Legorooj
    Member

    #4698 is a "fix" as such, meaning it'll now tell you that you need to remove X custom hook - It actually tells you which one.

  14. matham commented on Mar 2, 2020

    @matham
    Contributor

    Should this be closed, given that the fix simply tells you which hook is duplicated? Or is overriding a hook present in pyinstaller source with a custom version of the hook not officially supported?

  15. Legorooj commented on Mar 3, 2020

    @Legorooj
    Member

    @matham if you want to override default hooks, you currently have to edit the PyInstaller one. Otherwise, submit a PR that adds an option --prefer-custom which, when presented with a custom hook and a default one, prefers the custom hook.

  16. Legorooj commented on Mar 3, 2020

    @Legorooj
    Member

    Btw this wasn't a bug; it's simply the absence of an error message.

  17. locked as resolved and limited conversation to collaborators on Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions