Repository: spyder-ide/spyder

Issue:
IPython.core.inputtransformer2 is only present in IPython >= 7.0
<!--- **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
* [ ] 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)
* [ ] Tried basic troubleshooting (if a bug/error)
    * [x] Restarted Spyder
    * [x] Reset preferences with ``spyder --reset``
    * [ ] Reinstalled the latest version of [Anaconda](https://www.anaconda.com/download/)
    * [ ] Tried the other applicable steps from the Troubleshooting Guide
* [ ] Completed the **Problem Description**, **Steps to Reproduce** and **Version** sections below

## Problem Description
I am using spyder3 installing it system wide. Made a test by installing python-ipython version 6.5.0 and run into this issue.

```
$ spyder3
Traceback (most recent call last):
  File "/usr/bin/spyder3", line 3, in <module>
    start.main()
  File "/usr/lib/python3.7/site-packages/spyder/app/start.py", line 204, in main
    mainwindow.main()
  File "/usr/lib/python3.7/site-packages/spyder/app/mainwindow.py", line 3763, in main
    mainwindow = run_spyder(app, options, args)
  File "/usr/lib/python3.7/site-packages/spyder/app/mainwindow.py", line 3638, in run_spyder
    main.setup()
  File "/usr/lib/python3.7/site-packages/spyder/app/mainwindow.py", line 945, in setup
    from spyder.plugins.ipythonconsole.plugin import IPythonConsole
  File "/usr/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/plugin.py", line 46, in <module>
    from spyder.plugins.ipythonconsole.widgets import (ClientWidget,
  File "/usr/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/widgets/__init__.py", line 16, in <module>
    from .debugging import DebuggingWidget
  File "/usr/lib/python3.7/site-packages/spyder/plugins/ipythonconsole/widgets/debugging.py", line 22, in <module>
    from IPython.core.inputtransformer2 import TransformerManager
ModuleNotFoundError: No module named 'IPython.core.inputtransformer2'
```
This module 'IPython.core.inputtransformer2' is present in IPython version 7 series, and spyder 4.x need it.


Discussion:
Hey @algent-al, thanks for reporting. We do support older IPython versions, but we are not importing that module correctly. We'll fix that in our next version.

Resolving patch:
diff --git a/spyder/plugins/ipythonconsole/widgets/debugging.py b/spyder/plugins/ipythonconsole/widgets/debugging.py
--- a/spyder/plugins/ipythonconsole/widgets/debugging.py
+++ b/spyder/plugins/ipythonconsole/widgets/debugging.py
@@ -9,19 +9,21 @@
 mode and Spyder
 """
 
+from distutils.version import LooseVersion
 import re
 import pdb
 
+from IPython import __version__ as ipy_version
 from IPython.core.history import HistoryManager
 from qtconsole.rich_jupyter_widget import RichJupyterWidget
 
 from spyder.config.base import get_conf_path
 from spyder.config.manager import CONF
-from spyder.py3compat import PY2
-if not PY2:
-    from IPython.core.inputtransformer2 import TransformerManager
-else:
+
+if LooseVersion(ipy_version) < LooseVersion('7.0.0'):
     from IPython.core.inputsplitter import IPythonInputSplitter
+else:
+    from IPython.core.inputtransformer2 import TransformerManager
 
 
 class PdbHistory(HistoryManager):
@@ -277,7 +279,7 @@ def _is_pdb_complete(self, source):
         """
         if source and source[0] == '!':
             source = source[1:]
-        if PY2:
+        if LooseVersion(ipy_version) < LooseVersion('7.0.0'):
             tm = IPythonInputSplitter()
         else:
             tm = TransformerManager()


Test patch: