问题
I just run into an error that said "No module name socketio", after adding it to the hidden imports I get "No module name server" and after adding to the hidden imports socketio.server I get the new one and so on... Is there another way to add every import my application needs?
However if I have to go this way, how can I add import: from .exceptions import WebSocketError, since geventwebsocket.exceptions.WebSocketError is not working.
[EDIT] Here is more informations. My application works fine from PyCharm, after I create exe with Pyinstaller I get that error, I was doing research for adding imports that Pyinstaller did not caught and all I could find is to change .spec and to add to the hidden-imports what I need. However I thought that adding geventwebsocket will be enough but as I said, now I get "Cannot import name WebSocketError ". So I guess my code is ok since it works perfectly before I created exe with Pyinstaller?
[EDIT] Here is my .spec:
# -*- mode: python -*-
a = Analysis(['manage.py'],
pathex=['C:\\path'],
hiddenimports=['greenlet', 'hid', 'flask_bootstrap',
'flask_socketio', 'blueprints',
'hidapi', 'pywin32', 'xlrd', 'flask_wtf',
'flask_sqlalchemy', 'cython',
'flask_login', 'nexus', 'antiorm', 'colorama',
'socket.error','config', 'cython',
'flask_script', 'init','py', 'requests',
'PyInstaller', 'pyDatalog', 'pytest',
'yaml', 'terminal', 'virtualenv',
'geventwebsocket.server',
'gevent.server', 'socketio', 'socketio.server',
'gevent.pywsgi',
'gevent.baseserver','geventwebsocket.handler',
'socketio.handler',
'geventwebsocket.exceptions.WebSocketError',
'socketio.transports',
'socketio.exceptions.WebSocketError'],
hookspath=None,
runtime_hooks=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='manage.exe',
debug=False,
strip=None,
upx=True,
console=True )
dict_tree = Tree('app', prefix = 'app')
dict_tree += Tree('.hg', prefix = '.hg')
dict_tree += Tree('.idea', prefix = '.idea')
coll = COLLECT(exe,
a.binaries,
dict_tree,
a.zipfiles,
a.datas,
strip=None,
upx=True,
name='manage')
And error:
Traceback (most recent call last):
File "C:\Users\path\out00-PYZ.pyz\socketio.transports", line 4, in <module>
ImportError: cannot import name WebSocketError
来源:https://stackoverflow.com/questions/32913080/pyinstaller-hidden-imports-websocketerror