Why IPython Console in Spyder4 updates constantly when connecting to remote kernel on server? - python

I followed the instructions on the official Spyder page and successfully connected to remote kernel via SSH. However I have a problem in my Ipython Console as it refreshes every 2-3 seconds adding In [1]: lines infinitely. I suppose it is refreshing of a state on server, but could someone explain what is this, why this happens and can I turn it off, so that the Console behaves the same as when I work on my local kernel(without infinite adding of empty lines)?

The solution could be found here in post of scott-8: https://github.com/spyder-ide/spyder/issues/10240#issuecomment-543913159
The copy of the answer:
Don't know about the issue above, but here is what solved my issue for anyone reading: instead of running python -m spyder_kernels.console and connecting to the kernel, quit the kernel after running it. Then restart the kernel with python -m spyder_kernels.console -f kernel-xxxxx.json, specifying the file that was just created in the runtime directory, and connect to it. This fixed my problem for some reason.

Related

How to close kernel environment after calling "ipython kernel" in windows console?

I want to use spyder on my local machine but by using a kernel of a remote server. Achieving this requires finding the connection json file as described here. The location of this file is required to transfer this json file via a SFTP client to my local machine, such that I can use it to connect my local spyder IDE.
The problem is that if I type "ipython kernel" in the console I get the info
NOTE: When using the ipython kernel entry point, Ctrl-C will not work.
To exit, you will have to explicitly quit this process, by either sending
"quit" from a client, or using Ctrl-\ in UNIX-like environments.
To read more about this, see https://github.com/ipython/ipython/issues/2049
To connect another client to this kernel, use:
--existing kernel-somenumber.json
After entering this environment I'm somehow not able to do anything anymore - whatever I type in (%exit, quit) or trying to find the path to the json file as indicated above does not work either. Simply nothing seems to happen. Has someone else encountered this? Which command can I use in the console to quit this environment? The github link given above does somehow not help me either.

Working & debugging remotely with VS code & jupyter notebook

I have recently started working with VS-Code & Python Jupyter Notebook remotely using SSH and it was great until now. Almost had the experience of working directly on the server as I was able to execute and debug the notebook cells.
As I swapped between servers (containers / VDIs with the same file system), something might have happened to the remote extensions. The debugging had stopped working. I click on the debug button for a notebook cell, but the debug toolbar does not reach the breakpoint. The step option does not appear on the debugging screen.
Any suggestions on how to analyze/solve this would be appreciated.
Thanks
Looking on the vscode various logs (I think it was the python log) I found an exception occurs when I tried to step a single line. Searching further on the network I found this:
https://github.com/microsoft/vscode-jupyter/issues/8803
In short downgrading my ipykernel package from 6.8.0 to 6.7.0 did the trick and solved my problem.

How to let the python script (abc.py) keep executing on AWS even after Connection lost or SSH connection is terminated?

I was using Jupyter notebook on AWS AMI and using the port forwarding on Windows using PuTTY. I got my connection terminated and all the work of 24 hours is lost now and I'm unable to get that. So I used a script instead of Notebook and the same thing happened. I used to think that the process would keep going on even if the Shell connection is lost. But next time I login, I don't see anything.
I used top, htop aux to find if my processes are still running but they don't show my process. Please help how can I stop this from happening.
I am using Windows on 10 with Putty on local and Ubuntu 18 on the AWS AMI.
You can try
nohup python3 myscript.py &
Try the tmux
apt install tmux
I often use it to keep my web runing on server(not professional but convenient)
You can use screen.
You can install it wit:
sudo apt install screen
You can find more information right here: https://linuxize.com/post/how-to-use-linux-screen/

Starting Spyder/Jupyter Kernel on Server headless

I want to connect my local spyder-ide to a remote spyder-kernel running on our ML-server. but as soon as i shut down the console, the kernel halts. is there a way to start the kernel in the background and keep it running ?
i can start a kernel with python -m spyder_kernel.console on the server and can connect to it. but this opens a ipython console on the server. as soon as I close it, the kernel shuts down. is there a possibilty to start this kernel like "nohup" or headless.
i can do it with jupyter kernel& , but then i'm missing the spyder functionalities like the variable explorer in the IDE.
thanks for your help !
python -m spyder_kernels.console& resolved the question !

using flask in spyder stuck in local server

I am trying to create a web application using flask. I have already gotten somewhat comfortable with using python, and have done so using spyder, inside of Anacanda Navigator. Now I am playing around with flask doing basic functions and have successful so far by testing it out in local server 127.0.0.1:5000. The problem I am having is that I cannot stop the server once I run the script in spyder. I have stopped the script and run other scripts through the console, but the local server remains the same.
The reason this is a problem for me is because when I try to change files and run a different flask script, the server does not update with the new information. For example, if I run a flask script that returns "Hello World" on the main page, and then I stop that file, open a new file that has a different flask script that returns "The sky is blue" the server does not change when I check it on chrome or any other browser. It will onyl return "Hello World"
I have been able to fix this problem by completely restarting my computer, but I am wondering if there is another way, just to restart the local server, 127.0.0.1:5000. Thank You!
Also I am using windows
I do : "Run > Configuration per file > Execute in an external system terminal",
then when you run your .py containing the app.run, it will be launched in an external console. If you close the console the server will be closed too.
To Kill the local server, you may use Ctrl+C command and not any other command. This command is also mentioned when the server is up and running.
I've been having this precise issue and have been smashing my head against the wall for a couple of hours. I posted the referenced StackOverflow question (my first actually) and it seems that running a script from inside Spyder is the wrong way to go as it leaves runaway background processes running, even after restarting Spyder.
I got the recommendation to only launch my *.py code from the command prompt. Furthermore I was told to do this:
set FLASK_APP=main1.py then set FLASK_DEBUG=1 then flask run
though I'm not sure what that does, so I will investigate. I was about to restart my computer as a last ditch effort until I looked in my Windows Task Manager and found some Python tasks running. After [end task] them both I was able to launch the updated webpage on my local host.

Categories