Plotting in VS Code-Server (Python) - python

I setup a Visiual Studio Code-Sever on a Raspbarry Pi. I access the server via Safari from my Ipad. I can run scripts but I can not output plots. It is obvious that plt.show() does not work so I tried jupyter, but the interactive window remains black after I run the cell. There is no error to report but vs code is trying to install jupyter once again, although it is installed in my virtual environment. Similar problems occur when I try to start the output pane of neuron (it is not showing up at all).
Does anyone have ideas or ever had similar errors? It seems that jupyter cannot be accessed correctly.
Best regards!

Related

Python kernel automatically changes back to base in VS Code

I am trying to connect to a different environment for jupyter notebook in VS Code. I have settings.json as in the following:
"python.defaultInterpreterPath": "C:\\Users\\username\\.conda\\envs\\analytics\\python.exe"
I have manually added python path in select python interpreter
I have tried almost every solution, but I am unable to change kernel. Whenever I Reload Window it selects the intended kernel for a few seconds and then it changes back to base. I have never encountered this problem before, I have just installed anaconda and VS Code on this system. Can someone help me with this problem?

Show matplotlib figures during debug in visual studio code (using ssh conection)

I am working with visual studio code (python) using ssh to access a remote server (where the code is located). I am able to write code, run and debug without any problem. However I am not able to generate matplotlib figures during debug in the same way as i can do it without the ssh connection.
I've tried to follow several suggestions from internet and other post here but none of them is fully working.
I've tried the option of " Jupiter> Debug current file in interactive window " but it does not work. I am not sure why, but the debug in the interactive window is not responding and i can not work during debug.
I've tried python debug and the only matplotlib backend that works is (matplotlib.use("WebAgg"). However for this backend it only works with one figure and the debug is block after the plot.
I have also tried to use X.Org (in my case xquartz over mac) but the figures are really slow and it is not useful.
Any idea on how to plot figures during debug in the same way as in local development?
Thanks!
I asked this question in GitHub and got the following answers:
One way to do this is to do the 'Debug your current file in the interactive window'.
There's a bunch of caveats though.
You need to have ipykernel installed into the python environment
you're using. If you run that command it should have asked you to do
so.
It's likely easier to use if you put cell markers around pieces of
code # %%. This would also allow you to prerun bits of your script
before you need to debug the part that's causing problems. This is
what it looks like when you do that:
When debugging in the interactive window, your code in your script
is running as an IPython cell. If you split it up, it might be
multiple cells or it could be one large cell (for the whole file).
As you step, the cell execution is moved forward one line at a time.
However the execution is paused in between steps. This means
anything you type in the interactive window won't be executed.
Instead you have to run extra code in the 'debugger console'. Shown
below:
This debugger console is where you can run normal matplotlib
commands.

Jupyter notebook kernel keeps dying (no anaconda, ubuntu, cpu)

I setup jupyter notebook on a server(Ubunutu) to run but every 20-30min the kernel just dies and tries to restart.
I already googeled but I don't use anaconda, I don't get any specific error and it doesn't look like a specific function which fails so most 'solutions' do not apply to my case it seems.
The code runs on cpu.
However the code does work on my local machine (windows) running on gpu.
I also run the notebook with --debugger but I don't get any error it just says reconnect out of nowhere :(
Has anyone of you encountered a similar problem? It is hard to figure out what is going on without having any error messages :/
Thanks for your help!

Jupyter Running Wrong Cell in VSCode

I'm using the Jupyter extension on VSCode, Windows 10. I'm using Python through Anaconda.
I'm using a jupyter notebook and am running several different cells. After I run some of the cells a few times and restart the kernel a few times (to allow modules that I edited to update for the notebook), the notebook eventually stops running the correct cell. No matter what cell I try to run, it always runs the same cell, which is directly below my most used cell/the cell I used last. Opening and closing VSCode works but is only a temporary solution, and the issue has been arising more often. Does anyone know how to fix this?

Jupyter Notebook Kernel Crashing in VSCODE

I am interested in using VSCode's Jupyter notebook functionality and I am just trying to get to grips with it. I can start the kernel and run the notebook cells in VSCode.
After running particular cells it seems to crash with no warning and the code fails as the variables have been cleared. I have to reselect the kernel in the top right and start running the code again from the beginning until I get to the problem cells, and then the issue repeats itself.
I don't think it's anything to do with the Python code, it's some simple dataframe manipulation. I have tried the same notebook just running it in the browser and it works fine.I am running Jupyter through a venv with Python 3.7.6, MacOS Catalina (10.15.4), VSCode 1.45.1.
Something I noticed that might help indicate what is happening, is when it crashes I can run basic python statements in the notebook cells (without reselecting the kernel). But when I run my cell which tries to import tests from a .py file in the same folder or import data files using a relative path, it can't find them until I reselect the kernel. It seems like the cwd has changed? Can anyone assist with this?

Categories