ImportError: cannot import QtWebEngineWidgets after Spyder upgrade – impact on user plugins
0 reputation · 23 Jul 2024, 14:10 UTC
0 reputation · 23 Jul 2024, 14:10 UTC
After a botched Spyder upgrade, the IDE may fail to start with an ImportError such as “cannot import name 'QtWebEngineWidgets' from PyQt5.QtWebEngineWidgets”. The documented recovery paths are launching Spyder with --reset (which restores default preferences and removes user‑specific plugins) or using --safe mode (which disables third‑party plugins while preserving the existing configuration).
Users who rely on custom layouts, pane arrangements, or installed plugins face a trade‑off: a full reset eliminates those personalizations, whereas safe mode may still leave the IDE unable to launch if the underlying Qt bindings remain mismatched. The current behavior does not specify whether an automatic recovery mechanism should selectively preserve user‑installed plugins while clearing only corrupted configuration files, or whether it should treat all user data as expendable.
What criteria should determine which user data is retained during a post‑upgrade recovery? Should Spyder offer a middle‑ground option that resets only the configuration directory while leaving the plugins folder intact? Is there a need for a configurable fallback that attempts safe mode first and only resets if safe mode fails?
33775 reputation · 23 Jul 2024, 21:41 UTC
The practical criterion for retaining user data during a post-upgrade recovery is version-agnostic data not implicated in the crash. Plugin code is version-specific and often breaks across Spyder releases; layouts and preferences are more portable but can contain references to missing plugins. Corrupted configuration files (e.g., spyder.ini with bad plugin entries) should be reset. The QtWebEngineWidgets ImportError is typically an environment-level package mismatch (PyQt5 vs. PyQtWebEngine versions), not a Spyder configuration issue—neither --reset nor --safe-mode fixes the underlying binary incompatibility.
--reset: Deletes the entire configuration directory (~/.spyder or %APPDATA%\spyder), including the plugins subfolder, layouts, and preferences. Recreates defaults. This is a nuclear option that guarantees a clean state but loses all user customizations.--safe-mode: Starts Spyder with only core plugins enabled while reading the existing configuration. It does not modify the config directory. If the crash stems from a corrupted plugin entry in config, safe mode may bypass it; if the error is a broken PyQt5/QtWebEngine installation, safe mode will still crash.No. Spyder 5.x/6.x stores user plugins in a plugins subdirectory under the config dir. The current --reset implementation removes the entire config tree—there is no built-in flag to reset only configuration files (spyder.ini, layout.ini) while preserving the plugins folder. Feature requests for granular reset exist in Spyder's issue tracker but remain unimplemented as of Spyder 5.4.x. The documented manual workaround: back up ~/.spyder/plugins, run spyder --reset, then restore plugins selectively.
Not currently possible within Spyder itself. A fallback that attempts safe mode first and only resets if safe mode fails would require Spyder to detect startup failure before the application event loop starts—which it cannot do reliably. External wrapper scripts or OS-level restart policies would be needed. The practical workflow today is:
python -c "import PyQt5.QtWebEngineWidgets; print('OK')". If this fails, fix the package mismatch first (pip install PyQtWebEngine or align PyQt5/QtWebEngine versions).spyder --safe-mode. If it starts, the issue is likely a third-party plugin; disable/remove the offending plugin via the plugin manager.~/.spyder/plugins, run spyder --reset, then restore plugins one by one.What is your Spyder version? Run spyder --version or check Help > About. Spyder 4.x uses a different config structure; the above applies to Spyder 5.x and 6.x. The --safe-mode flag was added in Spyder 5.0—older versions lack this option entirely.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.