Repository: spyder-ide/spyder

Issue:
"SyntaxError: invalid syntax" when creating kernel manager
## Description

**What steps will reproduce the problem?**

1. 
2. 
3. 

**What is the expected output? What do you see instead?**


**Please provide any additional information below**

  File "/home/jiangao/anaconda3/lib/python3.6/site-packages/spyder/plugins/ipythonconsole.py", line 1324, in close_client
    self.create_new_client()
  File "/home/jiangao/anaconda3/lib/python3.6/site-packages/spyder/plugins/ipythonconsole.py", line 1033, in create_new_client
    self.connect_client_to_kernel(client)
  File "/home/jiangao/anaconda3/lib/python3.6/site-packages/spyder/plugins/ipythonconsole.py", line 1059, in connect_client_to_kernel
    stderr_file)
  File "/home/jiangao/anaconda3/lib/python3.6/site-packages/spyder/plugins/ipythonconsole.py", line 1477, in create_kernel_manager_and_kernel_client
    config=None, autorestart=True)
  File "/home/jiangao/anaconda3/lib/python3.6/site-packages/traitlets/traitlets.py", line 958, in __new__
    inst.setup_instance(*args, **kwargs)
  File "/home/jiangao/anaconda3/lib/python3.6/site-packages/traitlets/traitlets.py", line 986, in setup_instance
    super(HasTraits, self).setup_instance(*args, **kwargs)
  File "/home/jiangao/anaconda3/lib/python3.6/site-packages/traitlets/traitlets.py", line 977, in setup_instance
    value.instance_init(self)
  File "/home/jiangao/anaconda3/lib/python3.6/site-packages/traitlets/traitlets.py", line 1691, in instance_init
    self._resolve_classes()
  File "/home/jiangao/anaconda3/lib/python3.6/site-packages/traitlets/traitlets.py", line 1696, in _resolve_classes
    self.klass = self._resolve_string(self.klass)
  File "/home/jiangao/anaconda3/lib/python3.6/site-packages/traitlets/traitlets.py", line 1507, in _resolve_string
    return import_item(string)
  File "/home/jiangao/anaconda3/lib/python3.6/site-packages/traitlets/utils/importstring.py", line 34, in import_item
    module = __import__(package, fromlist=[obj])
  File "/home/jiangao/anaconda3/lib/python3.6/site-packages/jupyter_client/session.py", line 61, in <module>
    from jupyter_client.jsonutil import extract_dates, squash_dates, date_default
  File "/home/jiangao/anaconda3/lib/python3.6/site-packages/jupyter_client/jsonutil.py", line 11, in <module>
    from dateutil.parser import parse as _dateutil_parse
  File "/home/jiangao/anaconda3/lib/python3.6/site-packages/dateutil/parser.py", line 158
    l.append("%s=%s" % (attr, `value`))
                              ^
SyntaxError: invalid syntax


## Version and main components

* Spyder Version: 3.2.6 
* Python Version: 3.6.4
* Qt Versions: 5.6.2, PyQt5 5.6 on Linux

## 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  :  None (NOK)
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)
psutil >=0.3     :  5.4.3 (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:
It seems you're using a very old version of `dateutil` (probably one that doesn't have good support for Python 3).

So please run

    conda update python-dateutil

to fix this.
We will improve this by showing this kind of errors inside our consoles.

Resolving patch:
diff --git a/spyder/plugins/ipythonconsole.py b/spyder/plugins/ipythonconsole.py
--- a/spyder/plugins/ipythonconsole.py
+++ b/spyder/plugins/ipythonconsole.py
@@ -20,6 +20,7 @@
 import os.path as osp
 import uuid
 import sys
+import traceback
 
 # Third party imports
 from jupyter_client.connect import find_connection_file
@@ -1533,7 +1534,7 @@ def create_kernel_manager_and_kernel_client(self, connection_file,
         # Kernel spec
         kernel_spec = self.create_kernel_spec(is_cython=is_cython)
         if not kernel_spec.env.get('PYTHONPATH'):
-            error_msg = _("This error was most probably caused by installing "
+            error_msg = _("This error is most probably caused by installing "
                           "Spyder in a directory with non-ascii characters "
                           "(i.e. characters with tildes, apostrophes or "
                           "non-latin symbols).<br><br>"
@@ -1542,8 +1543,13 @@ def create_kernel_manager_and_kernel_client(self, connection_file,
             return (error_msg, None)
 
         # Kernel manager
-        kernel_manager = QtKernelManager(connection_file=connection_file,
-                                         config=None, autorestart=True)
+        try:
+            kernel_manager = QtKernelManager(connection_file=connection_file,
+                                             config=None, autorestart=True)
+        except Exception as e:
+            error_msg = _("The error is:<br><br>"
+                          "<tt>{}</tt>").format(traceback.format_exc())
+            return (error_msg, None)
         kernel_manager._kernel_spec = kernel_spec
 
         # Save stderr in a file to read it later in case of errors


Test patch: