Jupyter Notebook Kernel Crashing in VSCODE - python

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?

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?

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?

How to debug Jupyter Notebook profile_default/startup File?

I am placing a .py file in Jupyter Notebook profile_default/startup folder. It has some problems, I want to debug and see the logs. Is there any way I see the output or logs generated by that file. I am on windows 10. There are a few methods .py file. I am using keyboard module to generate a hotkey whenever the notebook starts. It isn't working for me. Please suggest a good way to at least debug that file. My ipykernel is 5.3.4 and ipython 7.16.1
The easiest way I've found so far is to fire up ipython from your console.
Assuming the error is not specific to how Jupyter starts the kernel, you will see the error with the stacktrace before the ipython shell starts.
If the error is specific to jupyter kernel, use jupyter kernel. It will start the kernel you specify, and drop a log line if there's an error.

Plotting in VS Code-Server (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!

Why will my python script only run in Jupyter Notebook, but not in VS Code if I am running the same interpreter for each?

I would just like to say off the bat, that I am very new to programming and this could be a real quick fix.
I am having trouble running a python script out of a standard VS Code from my 'base' conda env: python 3.7.6, but for some reason the same code when transferred into a jupyter notebook or even ran from the makeshift jup notebook on VS CODE it works fine.
When I run the code in the standard VS Code with the same python interpreter, I continue to have the following errors:
I would really like to learn how to avoid this in the future, because I prefer to write in VS Code modules instead of out of Jup. Notebooks.
Thanks for the help!
data= pickle.load(open('myData.pickle','rb'))
_pickle.UnpicklingError: invalid load key, '\xef'.
Here I also attached the image of the jup notebook output to show that the code runs fine on its own when not in a standard script .py file. Since I am new, the best I can do is leave the link to the image.

Categories