Repository: spyder-ide/spyder

Issue:
Error when connecting to external kernels
 
<!---   *** 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 --->

I was trying to connect to a remote ipython2 kernel (consoles > connect to an existing kernel), selected the .json file, ticked "this is a remote kernel", added my host name. This procedure used to work in previous versions, but for now it doesn't (qt console version is currently on 4.3.1). Thanks for any help

### Traceback
```python-traceback
  File "/usr/local/lib/python2.7/dist-packages/spyder/plugins/ipythonconsole.py", line 1060, in create_client_for_kernel
    password)
  File "/usr/local/lib/python2.7/dist-packages/spyder/plugins/ipythonconsole.py", line 1782, in _create_client_for_kernel
    client.shellwidget.kernel_client = kernel_client
  File "/usr/local/lib/python2.7/dist-packages/qtconsole/base_frontend_mixin.py", line 57, in kernel_client
    kernel_client.iopub_channel.message_received.connect(self._dispatch)
AttributeError: 'QtKernelClient' object has no attribute 'iopub_channel'
```

## Package Versions

* Spyder version: 3.2.8 
* Python version: 2.7.12
* Qt version: 4.8.7
* PyQt4 (API v2) version: 4.11.4
* Operating system: Linux 4.13.0-38-generic

### Dependencies

```
pyflakes >=0.5.0  :  1.6.0 (OK)
pycodestyle >=2.3 :  2.4.0 (OK)
pygments >=2.0    :  2.2.0 (OK)
pandas >=0.13.1   :  0.22.0 (OK)
numpy >=1.7       :  1.14.2 (OK)
sphinx >=0.6.6    :  1.7.4 (OK)
rope >=0.9.4      :  0.10.7 (OK)
jedi >=0.9.0      :  0.12.0 (OK)
psutil >=0.3      :  5.4.5 (OK)
nbconvert >=4.0   :  5.3.1 (OK)
sympy >=0.7.3     :  1.1.1 (OK)
cython >=0.21     :  None (NOK)
qtconsole >=4.2.0 :  4.3.1 (OK)
IPython >=4.0;<6.0:  5.6.0 (OK)
pylint >=0.25     :  1.8.4 (OK)
```



Discussion:
Thanks for reporting. We'll let the Jupyter guys know about this error so they can fix it.

Resolving patch:
diff --git a/spyder/plugins/ipythonconsole.py b/spyder/plugins/ipythonconsole.py
--- a/spyder/plugins/ipythonconsole.py
+++ b/spyder/plugins/ipythonconsole.py
@@ -1799,9 +1799,9 @@ def _create_client_for_kernel(self, connection_file, hostname, sshkey,
                 return
 
         # Assign kernel manager and client to shellwidget
+        kernel_client.start_channels()
         client.shellwidget.kernel_client = kernel_client
         client.shellwidget.kernel_manager = kernel_manager
-        kernel_client.start_channels()
         if external_kernel:
             client.shellwidget.sig_is_spykernel.connect(
                     self.connect_external_kernel)


Test patch:
diff --git a/continuous_integration/circle/modules_test.sh b/continuous_integration/circle/modules_test.sh
--- a/continuous_integration/circle/modules_test.sh
+++ b/continuous_integration/circle/modules_test.sh
@@ -7,13 +7,7 @@ export PYTHONPATH=.
 export PATH="$HOME/miniconda/bin:$PATH"
 source activate test
 
-
-if [ "$USE_PYQT" = "pyqt5" ]; then
-    conda install -q qt=5.* pyqt=5.* qtconsole matplotlib
-else
-    conda install -q qt=4.* pyqt=4.* qtconsole matplotlib
-fi
-
+conda install -q qt=5.* pyqt=5.* qtconsole matplotlib
 
 # Depth 1
 for f in spyder/*.py; do
diff --git a/spyder/plugins/tests/test_ipythonconsole.py b/spyder/plugins/tests/test_ipythonconsole.py
--- a/spyder/plugins/tests/test_ipythonconsole.py
+++ b/spyder/plugins/tests/test_ipythonconsole.py
@@ -21,7 +21,6 @@
 # Third party imports
 import cloudpickle
 from flaky import flaky
-import ipykernel
 from pygments.token import Name
 import pytest
 from qtpy import PYQT5
@@ -113,8 +112,6 @@ def close_console():
 @flaky(max_runs=3)
 @pytest.mark.auto_backend
 @pytest.mark.skipif(os.name == 'nt', reason="It times out sometimes on Windows")
-@pytest.mark.xfail(zmq.__version__ >= '17.0.0' and ipykernel.__version__ <= "4.8.1",
-                   reason="A bug with pyzmq 17 and ipykernel 4.8.1")
 def test_auto_backend(ipyconsole, qtbot):
     """Test that the automatic backend is working correctly."""
     # Wait until the window is fully up