Repository: spyder-ide/spyder

Issue:
Spyder crashes when launching after Windows standalone installation
<!--- **PLEASE READ:** When submitting here, please ensure you've completed the following checklist and checked the boxes to confirm. Issue reports without it may be closed. Thanks! --->

### Issue Report Checklist

* [x] Searched the [issues page](https://github.com/spyder-ide/spyder/issues?q=is%3Aissue) for similar reports
* [x] Read the relevant sections of the [Spyder Troubleshooting Guide](https://github.com/spyder-ide/spyder/wiki/Troubleshooting-Guide-and-FAQ) and followed its advice
* [ ] Reproduced the issue after updating with ``conda update spyder`` (or ``pip``, if not using Anaconda)
* [ ] Could not reproduce inside ``jupyter qtconsole`` (if console-related)
* [x] Tried basic troubleshooting (if a bug/error)
    * [x] Restarted Spyder
    * [ ] Reset preferences with ``spyder --reset``
    * [ ] Reinstalled the latest version of [Anaconda](https://www.anaconda.com/download/)
    * [x] Tried the other applicable steps from the Troubleshooting Guide
* [x] Completed the **Problem Description**, **Steps to Reproduce** and **Version** sections below

^ can not use anaconda or connect to internet with the computer I am installing on

## Problem Description
I have followed the installation instructions for the Spyder Window (standalone) installer. I have installed the latest python before as well. Tried installing and reinstalling Spyder for local and for everyone option and it still instantly crashes when launching. It keeps giving me this compatibility check error and then crashes

"Unfortunately, the library that Spyder-terminal use to create terminals is failing to work in your system. Therefore, this plugin will be deactivated. This usually happens on Windows 7 Systems. If that's the case, please consider updating to newer windows version"

even though I am on Windows 10 pro. I used the same installation process on my personal laptop and Spyder launched with no problems. Please help


### What steps reproduce the problem?

1. Install latest python
2. Install Spyder windows (standalone) installer
3. Launch Spyder

### What is the expected output? What do you see instead?
Spyder launches but immediately crashes without displaying the gui


### Paste Traceback/Error Below (if applicable)
<!--- Copy from error dialog or View > Panes > Internal Console --->

```python-traceback

fromIccProfile: failed minimal tag size sanity
Traceback (most recent call last):
 File "C:\Program Files\Spyder\Spyder.launch.pyw", line 35, in <module>
   main()
 File "C:\Program Files\Spyder\pkgs\spyder\app\start.py", line 256, in main
   mainwindow.main(options, args)
 File "C:\Program Files\Spyder\pkgs\spyder\app\mainwindow.py", line 1823, in main
   mainwindow = create_window(MainWindow, app, splash, options, args)
 File "C:\Program Files\Spyder\pkgs\spyder\app\mainwindow.py", line 203, in on_mainwindow_visible
   self.layouts.on.on_mainwindow_visible()
 File "C:\Program Files\Spyder\pkgs\spyder\plugins\layout\plugin.py", line 908, in create_plugins_menu
   action.setChecked(plugin.dockwidget.isVisible())
AttributeError: 'NoneType' object has no attribute 'isVisible'
Qprocess: Destroyed while process ("C:\\Program Files\\Spyder\\Python\\pythonw.exe") is still running.

```

## Versions
<!--- You can get this information from Help > About Spyder...
or (if Spyder won't launch) the "conda list" command
from the Anaconda Prompt/Terminal/command line. --->

* Spyder version: 5.4.3 (Windows Standalone)
* Python version: 3.11.4 (64-bit)
* Qt version: 5.15.2
* PyQt version: 5.15.9
* Operating System name/version: Windows 10 Pro


Discussion:
Hey @looka231, thanks for reporting and sorry for the inconvenience. We'll address this problem in our next version (5.4.4), to be released in a couple of days.

Resolving patch:
diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py
--- a/spyder/app/mainwindow.py
+++ b/spyder/app/mainwindow.py
@@ -382,18 +382,33 @@ def show_status_message(self, message, timeout):
         if status_bar.isVisible():
             status_bar.showMessage(message, timeout)
 
-    def show_plugin_compatibility_message(self, message):
+    def show_plugin_compatibility_message(self, plugin_name, message):
         """
         Show a compatibility message.
         """
         messageBox = QMessageBox(self)
+
+        # Set attributes
         messageBox.setWindowModality(Qt.NonModal)
         messageBox.setAttribute(Qt.WA_DeleteOnClose)
-        messageBox.setWindowTitle(_('Compatibility Check'))
-        messageBox.setText(message)
+        messageBox.setWindowTitle(_('Spyder compatibility check'))
+        messageBox.setText(
+            _("It was not possible to load the {} plugin. The problem "
+              "was:<br><br>{}").format(plugin_name, message)
+        )
         messageBox.setStandardButtons(QMessageBox.Ok)
+
+        # Show message.
+        # Note: All adjustments that require graphical properties of the widget
+        # need to be done after this point.
         messageBox.show()
 
+        # Center message
+        screen_geometry = QApplication.desktop().screenGeometry()
+        x = (screen_geometry.width() - messageBox.width()) / 2
+        y = (screen_geometry.height() - messageBox.height()) / 2
+        messageBox.move(x, y)
+
     def register_plugin(self, plugin_name, external=False, omit_conf=False):
         """
         Register a plugin in Spyder Main Window.
@@ -409,7 +424,7 @@ def register_plugin(self, plugin_name, external=False, omit_conf=False):
         plugin.get_description()
 
         if not is_compatible:
-            self.show_plugin_compatibility_message(message)
+            self.show_plugin_compatibility_message(plugin.get_name(), message)
             return
 
         # Connect plugin signals to main window methods
diff --git a/spyder/plugins/layout/plugin.py b/spyder/plugins/layout/plugin.py
--- a/spyder/plugins/layout/plugin.py
+++ b/spyder/plugins/layout/plugin.py
@@ -905,7 +905,13 @@ def create_plugins_menu(self):
                 action.action_id = f'switch to {plugin.CONF_SECTION}'
 
             if action:
-                action.setChecked(plugin.dockwidget.isVisible())
+                # Plugins that fail their compatibility checks don't have a
+                # dockwidget. So, we need to skip them from the plugins menu.
+                # Fixes spyder-ide/spyder#21074
+                if plugin.dockwidget is None:
+                    continue
+                else:
+                    action.setChecked(plugin.dockwidget.isVisible())
 
             try:
                 name = plugin.CONF_SECTION
@@ -935,6 +941,12 @@ def toggle_lock(self, value=None):
         self._update_lock_interface_action()
         # Apply lock to panes
         for plugin in self.get_dockable_plugins():
+            # Plugins that fail their compatibility checks don't have a
+            # dockwidget. So, we need to skip them from the code below.
+            # Fixes spyder-ide/spyder#21074
+            if plugin.dockwidget is None:
+                continue
+
             if self._interface_locked:
                 if plugin.dockwidget.isFloating():
                     plugin.dockwidget.setFloating(False)
@@ -965,7 +977,12 @@ def restore_visible_plugins(self):
         # Restore visible plugins
         for plugin in visible_plugins:
             plugin_class = self.get_plugin(plugin, error=False)
-            if plugin_class and plugin_class.dockwidget.isVisible():
+            if (
+                plugin_class
+                # This check is necessary for spyder-ide/spyder#21074
+                and plugin_class.dockwidget is not None
+                and plugin_class.dockwidget.isVisible()
+            ):
                 plugin_class.dockwidget.raise_()
 
     def save_visible_plugins(self):


Test patch: