PyInstaller does NOT work when including Pysnmp

后端 未结 3 1619
梦谈多话
梦谈多话 2020-12-22 00:48

Just trying one of the official documentation site examples:

from pysnmp.hlapi import *

errorIndication, errorStatus, errorIndex, varBinds = next(
    getCm         


        
3条回答
  •  醉话见心
    2020-12-22 01:44

    Got the same error "could not get source code". There is an issue about that created on Pyinstaller github page: https://github.com/pyinstaller/pyinstaller/issues/1945 Solution is to include ply to spec file as it is described in link you mentioned: Can't get pysnmp to work with pyinstaller by adding "PyInstaller.utils.hooks.collect_submodules('ply')" to hiddenimports

    And make sure ply version is >= 3.9!

    My spec file looks pretty much same except Analysis part:

    a = Analysis(['main.py'],
             binaries=None,
             datas=PyInstaller.utils.hooks.collect_data_files('pysnmp') + \
             hiddenimports=PyInstaller.utils.hooks.collect_submodules('pysmi')+\
             PyInstaller.utils.hooks.collect_submodules('ply') + \
             PyInstaller.utils.hooks.collect_submodules('pyasn1') + \
             PyInstaller.utils.hooks.collect_submodules('pysnmp'),
             hookspath=None,
             runtime_hooks=None,
             excludes=None,
             win_no_prefer_redirects=None,
             win_private_assemblies=None,
             cipher=block_cipher)
    

提交回复
热议问题