Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote spyder kernel not connecting #22555

Closed
9 of 10 tasks
reinaartvanloon opened this issue Sep 23, 2024 · 3 comments · Fixed by #22691
Closed
9 of 10 tasks

Remote spyder kernel not connecting #22555

reinaartvanloon opened this issue Sep 23, 2024 · 3 comments · Fixed by #22691

Comments

@reinaartvanloon
Copy link

reinaartvanloon commented Sep 23, 2024

Issue Report Checklist

  • Searched the issues page for similar reports
  • Read the relevant sections of the Spyder Troubleshooting Guide 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)
    • Restarted Spyder
    • Reset preferences with spyder --reset
    • Reinstalled the latest version of Anaconda
    • Tried the other applicable steps from the Troubleshooting Guide
  • Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

In Spyder 6.0 (spyder_kernels 3.0.0) I cannot connect to a remote kernel. In the Spyder 2.5.2, the steps I followed do work.
Manually forwarding the SSH ports as defined in the connection file or explicitly defining the IP-adress did not solve the problem. There seems to be no ssh connection problems when checking.

What steps reproduce the problem?

Following: https://docs.spyder-ide.org/current/panes/ipythonconsole.html

  1. Start a Spyder kernel on a remote machine (See shell script)
  2. Copy the connection file to the local machine (See shell script)
  3. Optional: Manually forward the SSH ports defined in the connection file. (See commented lines in shell script)
  4. Open spyder IDE on local machine and "Consoles">"Connect to an existing kernel"
  5. Set the path to the connection file on the local machine: ~/.local/share/jupyter/runtime/remote_kernel.json
  6. Set password for ssh connection to remote machine.
  7. Optional: Explicitly define the IP-adress as the 'hostname'
  8. Try connect to remote kernel

Shell script to run on local machine to reproduce steps 1 to 3:

#Run some commands on the remote machine --> activate python venv, start remote kernel and write out connection file: "remote_kernel.json"
ssh $user@$remote_host \
"source $remote_venv_path &&\
python -m spyder_kernels.console -f=remote_kernel.json  > ${remote_logpath}/spyderkernel_output.log 2>&1 &"
echo "Remote kernel started on $remote_host."

# Locate and copy connection file from the remote machine to the local machine
local_kernel_loc="$HOME/.local/share/jupyter/runtime/remote_kernel.json"
remote_kernel_path=$(ssh $user@$remote_host "jupyter --runtime")
remote_kernel_loc="$remote_kernel_path/remote_kernel.json"

echo "Local kernel location: $local_kernel_loc"
echo "Remote kernel location: $remote_kernel_loc"

scp $user@$remote_host:$remote_kernel_loc $local_kernel_loc
echo "Connection file copied to local machine."

#for port in $(cat $local_kernel_loc | grep '_port' | grep -o '[0-9]\+'); do
#    ssh $user@$remote_host -f -N -L $port:127.0.0.1:$port
#    echo "ssh port $port is opened!"
#done

What is the expected output? What do you see instead?

Expected: The remote kernel.
Reality: Errors about the ssh connection

Paste Traceback/Error Below (if applicable)

Traceback (most recent call last):
File "/home/rvloon/code/py_venv_test_local/lib/python3.10/site‑packages/spyder/plugins/ipythonconsole/widgets/main_widget.py", line 1801, in create_client_for_kernel
kernel_handler = KernelHandler.from_connection_file(
File "/home/rvloon/code/py_venv_test_local/lib/python3.10/site‑packages/spyder/plugins/ipythonconsole/utils/kernel_handler.py", line 453, in from_connection_file
kernel_client=cls.init_kernel_client(
File "/home/rvloon/code/py_venv_test_local/lib/python3.10/site‑packages/spyder/plugins/ipythonconsole/utils/kernel_handler.py", line 487, in init_kernel_client
kernel_client.tunnel_to_kernel(
File "/home/rvloon/code/py_venv_test_local/lib/python3.10/site‑packages/spyder/plugins/ipythonconsole/utils/client.py", line 110, in tunnel_to_kernel
self.__tunnel_handler = KernelClientTunneler.new_connection(
File "/home/rvloon/code/py_venv_test_local/lib/python3.10/site‑packages/spyder/api/asyncdispatcher.py", line 116, in wrapper
return cls(async_func, loop=loop, early_return=early_return)(
File "/home/rvloon/code/py_venv_test_local/lib/python3.10/site‑packages/spyder/api/asyncdispatcher.py", line 101, in __call__
return task.result()
File "/usr/lib/python3.10/concurrent/futures/_base.py", line 458, in result
return self.__get_result()
File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
raise self._exception
File "/home/rvloon/code/py_venv_test_local/lib/python3.10/site‑packages/spyder/plugins/ipythonconsole/utils/client.py", line 46, in new_connection
await asyncssh.connect(*args, **kwargs, known_hosts=None),
File "/home/rvloon/code/py_venv_test_local/lib/python3.10/site‑packages/asyncssh/connection.py", line 8834, in connect
return await asyncio.wait_for(
File "/usr/lib/python3.10/asyncio/tasks.py", line 408, in wait_for
return await fut
File "/home/rvloon/code/py_venv_test_local/lib/python3.10/site‑packages/asyncssh/connection.py", line 419, in _connect
_, tunnel_session = await new_tunnel.create_connection(
File "/home/rvloon/code/py_venv_test_local/lib/python3.10/site‑packages/asyncssh/connection.py", line 4569, in create_connection
session = await chan.connect(session_factory, remote_host, remote_port,
File "/home/rvloon/code/py_venv_test_local/lib/python3.10/site‑packages/asyncssh/channel.py", line 2037, in connect
return (await self._open_tcp(session_factory, b'direct‑tcpip',
File "/home/rvloon/code/py_venv_test_local/lib/python3.10/site‑packages/asyncssh/channel.py", line 2027, in _open_tcp
await self._open_forward(session_factory, chantype,
File "/home/rvloon/code/py_venv_test_local/lib/python3.10/site‑packages/asyncssh/channel.py", line 1999, in _open_forward
packet = await super()._open(chantype, *args)
File "/home/rvloon/code/py_venv_test_local/lib/python3.10/site‑packages/asyncssh/channel.py", line 714, in _open
return await self._open_waiter
asyncssh.misc.ChannelOpenError: No address associated with hostname

Versions

Local machine:

  • Spyder version: 6.0.0
  • Python version: 3.10.12 64 bit
  • Qt version: 5.15.14
  • PyQt version: 5.15.11
  • Operating System name/version: KDE neon 6.1, Linux 6.8.0-40-generic

Dependencies

# Mandatory:
aiohttp >=3.9.3                  :  3.10.5 (OK)
asyncssh >=2.14.0,<3.0.0         :  2.17.0 (OK)
atomicwrites >=1.2.0             :  1.4.1 (OK)
chardet >=2.0.0                  :  5.2.0 (OK)
cloudpickle >=0.5.0              :  3.0.0 (OK)
cookiecutter >=1.6.0             :  2.6.0 (OK)
diff_match_patch >=20181111      :  20230430 (OK)
github >=2.3.0                   :  2.4.0 (OK)
importlib_metadata >=4.6.0       :  8.5.0 (OK)
intervaltree >=3.0.2             :  3.1.0 (OK)
IPython >=8.13.0,<9.0.0,!=8.17.1 :  8.27.0 (OK)
jedi >=0.17.2,<0.20.0            :  0.19.1 (OK)
jellyfish >=0.7                  :  1.1.0 (OK)
jsonschema >=3.2.0               :  4.23.0 (OK)
keyring >=17.0.0                 :  25.4.1 (OK)
nbconvert >=4.0                  :  7.16.4 (OK)
numpydoc >=0.6.0                 :  1.8.0 (OK)
parso >=0.7.0,<0.9.0             :  0.8.4 (OK)
pexpect >=4.4.0                  :  4.9.0 (OK)
pickleshare >=0.4                :  0.7.5 (OK)
psutil >=5.3                     :  6.0.0 (OK)
pygments >=2.0                   :  2.18.0 (OK)
pylint >=3.1,<4                  :  3.3.0 (OK)
pylint_venv >=3.0.2              :  3.0.3 (OK)
pyls_spyder >=0.4.0              :  0.4.0 (OK)
pylsp >=1.12.0,<1.13.0           :  1.12.0 (OK)
pylsp_black >=2.0.0,<3.0.0       :  2.0.0 (OK)
pyuca >=1.2                      :  1.2 (OK)
qdarkstyle >=3.2.0,<3.3.0        :  3.2.3 (OK)
qstylizer >=0.2.2                :  0.2.3 (OK)
qtawesome >=1.3.1,<1.4.0         :  1.3.1 (OK)
qtconsole >=5.6.0,<5.7.0         :  5.6.0 (OK)
qtpy >=2.4.0                     :  2.4.1 (OK)
rtree >=0.9.7                    :  1.3.0 (OK)
setuptools >=49.6.0              :  59.6.0 (OK)
sphinx >=0.6.6                   :  8.0.2 (OK)
spyder_kernels >=3.0.0,<3.1.0    :  3.0.0 (OK)
superqt >=0.6.2,<1.0.0           :  0.6.7 (OK)
textdistance >=4.2.0             :  4.6.2 (OK)
three_merge >=0.1.1              :  0.1.1 (OK)
watchdog >=0.10.3                :  5.0.2 (OK)
xdg >=0.26                       :  0.28 (OK)
yarl >=1.9.4                     :  1.11.1 (OK)
zmq >=24.0.0                     :  26.2.0 (OK)

# Optional:
cython >=0.21                    :  None (NOK)
matplotlib >=3.0.0               :  None (NOK)
numpy >=1.7                      :  None (NOK)
pandas >=1.1.1                   :  None (NOK)
scipy >=0.17.0                   :  None (NOK)
sympy >=0.7.3                    :  None (NOK)

Remote machine:

  • Spyder version: 6.0.0
  • Python version: 3.12.5
  • Qt version: 5.15.14
  • PyQt version: 5.15.11
  • Operating System name/version: Fedora Linux 39, Linux 6.10.4-100
@jyk4100
Copy link

jyk4100 commented Oct 3, 2024

I am running into same error. Following using-external-kernels to connect to a remote kernel on a remote machine is not working with Spyder 6.0.0 and spyer-kernels==3.0.0.

When using password auth

An error occurred while starting the kernel
The error is:

Traceback (most recent call last):
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/spyder/plugins/ipythonconsole/widgets/main_widget.py", line 1801, in create_client_for_kernel
kernel_handler = KernelHandler.from_connection_file(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/spyder/plugins/ipythonconsole/utils/kernel_handler.py", line 453, in from_connection_file
kernel_client=cls.init_kernel_client(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/spyder/plugins/ipythonconsole/utils/kernel_handler.py", line 487, in init_kernel_client
kernel_client.tunnel_to_kernel(
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/spyder/plugins/ipythonconsole/utils/client.py", line 110, in tunnel_to_kernel
self.__tunnel_handler = KernelClientTunneler.new_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/spyder/api/asyncdispatcher.py", line 116, in wrapper
return cls(async_func, loop=loop, early_return=early_return)(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/spyder/api/asyncdispatcher.py", line 101, in __call__
return task.result()
^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/spyder/plugins/ipythonconsole/utils/client.py", line 46, in new_connection
await asyncssh.connect(*args, **kwargs, known_hosts=None),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/connection.py", line 8834, in connect
return await asyncio.wait_for(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/asyncio/tasks.py", line 452, in wait_for
return await fut
^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/connection.py", line 419, in _connect
_, tunnel_session = await new_tunnel.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/connection.py", line 4569, in create_connection
session = await chan.connect(session_factory, remote_host, remote_port,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/channel.py", line 2037, in connect
return (await self._open_tcp(session_factory, b'direct‑tcpip',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/channel.py", line 2027, in _open_tcp
await self._open_forward(session_factory, chantype,
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/channel.py", line 1999, in _open_forward
packet = await super()._open(chantype, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/channel.py", line 714, in _open
return await self._open_waiter
^^^^^^^^^^^^^^^^^^^^^^^
asyncssh.misc.ChannelOpenError: Name or service not known

using ssh_keyfile

An error occurred while starting the kernel
The error is:

Traceback (most recent call last):
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/spyder/plugins/ipythonconsole/widgets/main_widget.py", line 1801, in create_client_for_kernel
kernel_handler = KernelHandler.from_connection_file(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/spyder/plugins/ipythonconsole/utils/kernel_handler.py", line 453, in from_connection_file
kernel_client=cls.init_kernel_client(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/spyder/plugins/ipythonconsole/utils/kernel_handler.py", line 487, in init_kernel_client
kernel_client.tunnel_to_kernel(
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/spyder/plugins/ipythonconsole/utils/client.py", line 104, in tunnel_to_kernel
self.__tunnel_handler = KernelClientTunneler.new_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/spyder/api/asyncdispatcher.py", line 116, in wrapper
return cls(async_func, loop=loop, early_return=early_return)(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/spyder/api/asyncdispatcher.py", line 101, in __call__
return task.result()
^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/spyder/plugins/ipythonconsole/utils/client.py", line 46, in new_connection
await asyncssh.connect(*args, **kwargs, known_hosts=None),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/connection.py", line 8830, in connect
new_options = await SSHClientConnectionOptions.construct(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/connection.py", line 7112, in construct
return cast(_Options, await loop.run_in_executor(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/connection.py", line 7103, in __init__
super().__init__(options=options, last_config=last_config, **kwargs)
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/misc.py", line 383, in __init__
self.prepare(**self.kwargs)
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/connection.py", line 8015, in prepare
load_keypairs(cast(KeyPairListArg, client_keys), passphrase,
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/public_key.py", line 3571, in load_keypairs
key, certs_to_load = read_private_key_and_certs(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/public_key.py", line 3345, in read_private_key_and_certs
key, cert = import_private_key_and_certs(read_file(filename), passphrase,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/public_key.py", line 3209, in import_private_key_and_certs
key, end = _decode_private(data, passphrase,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/public_key.py", line 2801, in _decode_private
key = _decode_pem_private(pem_name, headers, data, passphrase,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/public_key.py", line 2707, in _decode_pem_private
return _decode_openssh_private(data, passphrase,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jyk4100/Library/spyder𔂰/envs/spyder‑runtime/lib/python3.11/site‑packages/asyncssh/public_key.py", line 2540, in _decode_openssh_private
raise KeyImportError('Passphrase must be specified to import '
asyncssh.public_key.KeyImportError: Passphrase must be specified to import encrypted private keys

@jyk4100
Copy link

jyk4100 commented Oct 4, 2024

@reinaartvanloon - have you tried "Consoles" > "New Console in a remote server". This works for me by for now except that I cannot specify a virtual environment :(

@ccordoba12
Copy link
Member

ccordoba12 commented Oct 4, 2024

Hey @reinaartvanloon and @jyk4100, thanks for reporting. It seems the new functionality we added in Spyder 6.0 to connect to remote servers introduced this bug for the old functionality. We'll try to fix it in a future version (6.0.3), to be released in a few weeks.

@jyk4100, you said:

have you tried "Consoles" > "New Console in a remote server". This works for me by for now except that I cannot specify a virtual environment :(

That's the new functionality I'm talking about. And we're working to add the ability to specify a remote virtual environment in 6.1, to be released in six months or so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants