Repository: spyder-ide/spyder

Issue:
Error when setting color scheme in the IPython console
 
<!---   *** BEFORE SUBMITTING: PASTE CLIPBOARD HERE TO COMPLETE YOUR REPORT ***   ---!>
<!--- **PLEASE READ:** Before submitting here, please carefully consult our *Troubleshooting Guide*: https://github.com/spyder-ide/spyder/wiki/Troubleshooting-Guide-and-FAQ and search the issues page for your error/problem, as most posted bugs are duplicates or easy fixes.

If you don't find anything, please provide a detailed step-by-step description (in English) of the problem and what led up to it below. Issue reports without a clear way to reproduce them will be closed. Thanks! --->

## Problem Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

Changing the default Emacs color scheme in Spyder caused it to crash


### Traceback
```python-traceback
  File "C:\Users\Skyler\Anaconda2\envs\py36\lib\site-packages\spyder\plugins\configdialog.py", line 214, in accept
    configpage.apply_changes()
  File "C:\Users\Skyler\Anaconda2\envs\py36\lib\site-packages\spyder\plugins\configdialog.py", line 104, in apply_changes
    self.apply_callback()
  File "C:\Users\Skyler\Anaconda2\envs\py36\lib\site-packages\spyder\plugins\configdialog.py", line 269, in <lambda>
    self.apply_settings(self.changed_options))
  File "C:\Users\Skyler\Anaconda2\envs\py36\lib\site-packages\spyder\plugins\configdialog.py", line 1183, in apply_settings
    self.main.ipyconsole.apply_plugin_settings(['color_scheme_name'])
  File "C:\Users\Skyler\Anaconda2\envs\py36\lib\site-packages\spyder\plugins\ipythonconsole.py", line 710, in apply_plugin_settings
    client.set_color_scheme(color_scheme_o)
  File "C:\Users\Skyler\Anaconda2\envs\py36\lib\site-packages\spyder\widgets\ipythonconsole\client.py", line 439, in set_color_scheme
    self.shellwidget.set_color_scheme(color_scheme, reset)
  File "C:\Users\Skyler\Anaconda2\envs\py36\lib\site-packages\spyder\widgets\ipythonconsole\shell.py", line 144, in set_color_scheme
    self.reset(clear=True)
  File "C:\Users\Skyler\Anaconda2\envs\py36\lib\site-packages\qtconsole\frontend_widget.py", line 665, in reset
    self._show_interpreter_prompt()
  File "C:\Users\Skyler\Anaconda2\envs\py36\lib\site-packages\qtconsole\jupyter_widget.py", line 348, in _show_interpreter_prompt
    msg_id = self.kernel_client.execute('', silent=True)
AttributeError: 'NoneType' object has no attribute 'execute'
```

## Package Versions

* Spyder version: 3.2.8 
* Python version: 3.6.4
* Qt version: 5.6.2
* PyQt5 version: 5.6
* Operating system: Windows 10

### Dependencies

```
pyflakes >=0.6.0 :  1.6.0 (OK)
pycodestyle >=2.3:  2.3.1 (OK)
pygments >=2.0   :  2.2.0 (OK)
pandas >=0.13.1  :  0.22.0 (OK)
numpy >=1.7      :  1.14.0 (OK)
sphinx >=0.6.6   :  1.6.6 (OK)
rope >=0.9.4     :  0.10.7 (OK)
jedi >=0.9.0     :  0.11.1 (OK)
nbconvert >=4.0  :  5.3.1 (OK)
sympy >=0.7.3    :  1.1.1 (OK)
cython >=0.21    :  0.27.3 (OK)
qtconsole >=4.2.0:  4.3.1 (OK)
IPython >=4.0    :  6.2.1 (OK)
pylint >=0.25    :  1.8.2 (OK)
```



Discussion:
Thanks for reporting. We'll fix this in our next release.
@dalthviz, please work on this one by catching `AttributeError` around `self.shellwidget.set_color_scheme(color_scheme, reset)` in the method `set_color_scheme` of `ClientWidget` (in client.py)

Resolving patch:
diff --git a/spyder/widgets/ipythonconsole/client.py b/spyder/widgets/ipythonconsole/client.py
--- a/spyder/widgets/ipythonconsole/client.py
+++ b/spyder/widgets/ipythonconsole/client.py
@@ -436,7 +436,12 @@ def set_infowidget_font(self):
 
     def set_color_scheme(self, color_scheme, reset=True):
         """Set IPython color scheme."""
-        self.shellwidget.set_color_scheme(color_scheme, reset)
+        # Needed to handle not initialized kernel_client
+        # See issue 6996
+        try:
+            self.shellwidget.set_color_scheme(color_scheme, reset)
+        except AttributeError:
+            pass
 
     def shutdown(self):
         """Shutdown kernel"""


Test patch: