Spyder: How to run Spyder kernel headless

Created on 11 Oct 2017  Â·  12Comments  Â·  Source: spyder-ide/spyder

I'm trying to use the kernel on my desktop from my laptop. The only issue is that when I use

ipython kernel

and connect to it, Spyder complains that set_cwd is not recognized, because that's a method in SpyderKernel class. So naturally, I'm wondering how I can create a headless instance of the Spyder kernel to connect to. Is there a way to do this?

Thanks

IPython Console Enhancement

Most helpful comment

This is solved now by spyder-kernels, i.e. you just need to install spyder-kernels in your remote server and run there

python -m spyder_kernels.console

All 12 comments

What I sometimes use to run an empty Spyderlike console is installing the Jupyter frame work using pip install jupyter . Then you can launch an ipython shell typing jupyter qtconsole.
More about the qtconsole https://qtconsole.readthedocs.io/en/stable/

I have jupyter console, tried it. It uses the IPythonKernel, which doesn't have set_cwd method.

I have a suspicion that the SpyderKernel uses some functionality of the IDE which might not be available but itself.

Edit: Hmm, I was able to start a SpyderKernel headless by manually launching the start_kernel.py file with a -f argument for the json file. Now, of course, the file explorer is trying to change the folder on that kernel to something that doesn't exist on that system but the good part is that the Variable explorer actually works from within that console!!

So if I can get the path somehow working (or get the file explorer to list the folders on the remote), it's gonna be really close to a local spyder console.

Edit 2: By perhaps leveraging a mounted disk and matching the whole path on both, the remote machine, and the local machine.

So naturally, I'm wondering how I can create a headless instance of the Spyder kernel to connect to. Is there a way to do this?

@AfzalivE, you need to install Spyder on your desktop, and then run this command

python <path to your installation>/spyder/utils/ipython/start_kernel.py

We're working to simplify this in Spyder 4.

@ccordoba12 should we have something like

$ spyder qtconsole subcomand?

Well, the idea is to move all our kernel code to a new package so that people don't need to install Spyder and all its dependencies to simply run our kernel.

Then the subcommand could look like

spykernel start

or something like that :-)

spykernel start

In that case we should just mimic the normal cli interface for ipython console, and forward everything + any specific spyder stuff?

@goanpeca I don't think starting the kernel starts the console. Running the ipython kernel command, for example just runs the kernel that other consoles can connect to.

@ccordoba12 looking forward to this version 4! Is there a way I could contribute? Has work started on it yet?

I tried that but spyder was showing errors, but I'll try after matching the paths and the mounted disk thing that I mentioned earlier. I guess that's the way until the file explorer can access the remote filesystem itself

Is there a way I could contribute?

For now the plans to extract our kernel code are in my head :-) But I'll post something here when I have created the new project.

Has work started on it yet?

Sure, we're about to release our first beta. You can see our current additions here.

Alright, for now. This is the workaround that works for me:

  1. Start the spyder kernel
    python /path/to/spyder/utils/ipython/start_kernel.py -f kernel-remote.json

(in my case this was way inside the anaconda folder)

  1. Fetch the kernel-remote.json file using scp
   scp server:/run/user/1000/jupyter/kernel-remote.json .
  1. Create the project folder on the remote server having the same absolute path as the client. In my case, I had to create /Users/username/Dev/mounted on my Ubuntu server (because the client is a Mac) and have all the shared files there

  2. Share the project folder on the remote server over the network. Samba in this case.

  3. Mount the samba share on the client side on the same path as in step 3. So really, this path can be anything but spyder doesn't see hidden folders on Mac, and you can't create anything inside /home on a Mac.

  4. Now open Spyder, use the file explorer to open the mounted folder. Connect the remote kernel using kernel-remote.json and enjoy without errors!

:D

Note: Plotting graphs will only work inline (even with the Automatic option). Haven't tried debugging yet.

This is solved now by spyder-kernels, i.e. you just need to install spyder-kernels in your remote server and run there

python -m spyder_kernels.console

This is solved now by spyder-kernels, i.e. you just need to install spyder-kernels in your remote server and run there

python -m spyder_kernels.console

but this doesn't start the kernel headless. as soon as i close my ssh-connection to the server, the kernel shuts down. is there a way to start the kernel and connect to it anytime i want without keeping an ssh connection open the server all the time?

You can use screen on your ssh server or byobu or simply execute the
headless commands in background with &. That is not a problem related to
Spyder.

On Tue, Apr 30, 2019, 5:34 AM m4tts notifications@github.com wrote:

This is solved now by spyder-kernels, i.e. you just need to install
spyder-kernels in your remote server and run there

python -m spyder_kernels.console

but this doesn't start the kernel headless. as soon as i close my
ssh-connection to the server, the kernel shuts down. is there a way to
start the kernel and connect to it anytime i want without keeping an ssh
connection open the server all the time?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/spyder-ide/spyder/issues/5441#issuecomment-487884815,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADKOWKCBTBDTOVKTACOQYTPTAHD5ANCNFSM4D6TU7JA
.

Was this page helpful?
0 / 5 - 0 ratings