Why my jupyter kernel is not visible in vs code jupyter extension? - python

I have my pyspark kernel installed using sparkmgic, it is showing in jupyter notebook and worked fine (connected to remote livy service and ran code without any issues). It is also visible when I use jupyter kernelspec list command, but when I tried to use vs code jupyter extension, it is not showing in the kernel list.
What is the reason it could be? how to fix it?
Thanks!

https://github.com/microsoft/vscode-jupyter/issues/8286
Got the answer from the one of code contributors on Github.
Just need to put python full path in the kernel configuration json file.

Related

VSCode python interactive window: fix nvidia gpu support for tensorflow / pytorch

I just want to give you the solution for my problem as it took me quite some time to solve it and like always, the solution was very simple.
It also addresses this github issue which was closed without answer: https://github.com/microsoft/vscode-jupyter/issues/1697
Problem
I properly setup the local installation of nvidia driver and tensorflow.
Running this snippet in python shell or .py file in a terminal (external or integrated vscode terminal) resulted in the following output:
# %%
import tensorflow as tf
gpus = tf.config.list_physical_devices('GPU')
print(gpus)hon
# Result: [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
But within python interactive window (jupyter notebook) by clicking -> Run cell,
I just received an empty list [].
Do you have the same problem?
Have a look at the output of the jupyter notebook by:
Vscode -> Terminal -> Output section -> Change top right to Jupyter and have a look at the error message
e.g. a library wasn't found
Have a look at the environment variable LD_LIBRARY_PATH which is used to set paths to c libraries and which is normally set/extended in the .bashrc file during installation of nvidia cuDNN.
In your terminal:
echo $LD_LIBRARY_PATH
In your ipython/jupyter interactive vscode cell
import os
os.environ["LD_LIBRARY_PATH"]
# If you receive a key error, then the variable isn't set
They should have the same output, e.g. /usr/lib/cuda/include:/usr/lib/cuda/lib64:
If they differ or you get an KeyError, then I can help you.
They differ, because the jupyter notebook is not started as a login shell and therefore does not load the bashrc, also does not have the exported variables.
Solution
The solution is to create a .env file in the python root directory of your project and include this content:
LD_LIBRARY_PATH=/usr/lib/cuda/include:/usr/lib/cuda/lib64:
Reload the VSCode Window, et voila, it worked without error.
I found the solution in these to links:
https://github.com/jupyter/notebook/issues/5871 -> Solution for jupyter notebook run externally (not within jupyter notebook)
https://github.com/microsoft/vscode-jupyter/issues/1467#issuecomment-767914345

Jupyter notebook in VS Code - No color for the python code in ipynb-file. What am i doing wrong?

Code of .ipynb file:
Python is detected:
The code has color in jupyter notebook:
I tried setting up a jupyter notebook in vs code in an anaconda environment. I have tried - Python: Select interpreter and selected my anaconda environment. Made sure python is in the environment: python --version: Python 3.8.8. Tried clicking on CVE(in the bottom right corner) to change to python (picture 2). The colorization of the code works fine in the interactive window of jupyter notebook (picture 3).
Jupyter extension detects your code as CVE instead of Python so Python syntax highlighting is not applied successfully.
Refer to Jupyter in vscode can't execute syntax highlighting, the Dependency Analytics extension should be the reason. Remove or Disable it then reload window, the question should go away.
Disable VS Code's extension "Dependency Analytics" to solve the missing Syntax Highlighting within Jupyter notebook files.
Disable "Dependency Analytics1
I had the same issue, and when I reloaded one of my extensions (it was Azure Functions in my case) everything was coloured as normal again. Weird...

VSCode Jupyter cannot update kernels automatically

I'm working on Ubuntu by remoteSSH, and I updated python kernel in my vitual environment named nn form 3.7.9 to 3.8.5, however, I still find the old kernel standing in the jupyter kernel list. I want to know how to delete the old kernel name from the kernel list.
I've replaced python 3.7.9 and python3.6.4 with python 3.8.5, but the old kernels didn't disappear, I want to delete them manually.
Moreover, I can't select Python 3.8.5 from the kernel list.
I had the same problem and the following might help someone else encountering the issue:
Reload VS Code Window by Ctrl+Shift+P and selecting Reload Window.
Reload the Python and Jupyter extensions under the Extensions in the Side Bar.
Quit and relaunch VS Code.
It seems that VS Code is not that quick to update the interpreter list.
Here's a workaround: in the command palette, search for Python: Select interpreter. You then get a dropdown with a little refresh button in the top right corner. After you refresh this list the new interpreter will be listed as a kernel for jupyter.
It looks like you have fixed your issue already. But in case anyone else hits this, or a similar issue. VS Code jupyter support looks in the standard jupyter locations for any installed kernelspecs you can see those directories listed here:
https://jupyter.readthedocs.io/en/latest/use/jupyter-directories.html#data-files
VS Code should pick up anything that Jupyter could pick up. So if you happen to have jupyter installed in a python environment then from the commandline you can run jupyter kernelspec list to see a list of all the kernelspecs installed on the system.
Ok I figured it out. There are kernel register files in the directorry
.local/jupyter/kernels/pythonxxxx
I manually delete python379 and python364 then everything is totally right.

Jupyter Notebooks in VS Code using WSL 2 are not working

I want to use Jupyter Notebooks inside VS Code running within WSL 2. Regular Python works within WSL without a problem, that means the base conda enviroment is connected and I can run .py files. Moreover, I’m able to run the command jupyter notebook which will start the notebook server within WSL exposing the localhost to the Windows system.
However, I want to test the new Jupyter Notebook feature within VS Code, which is not working for me; VS Code shows: Jupyter Server: No Kernel and Python: Not Started (see screenshot below).
My testing machine is:
WSL 2 (using Pengwin distribution) on Windows 20H1 (19041.21)
VS Code 1.41 (having the Python extension installed)
Anaconda
What I did:
Open WSL
Open VS Code in my target directory (code .)
Create a new Notebook file from the command palette Python: Create New Blank Jupyter Notebook
Create dummy print("test")
Run Cell will trigger the warning:
Is there anything I’m missing?
The VS Code insiders actually works out of box with Jupyter notebooks. Just remember to run code-insiders . instead of code ..
Another solution would be, according to this website, start the VS Code in windows, then use WSL 2 as a remote server.
The code installation on wsl2 needs a restart to work properly, I was told by a notification, and in the question's comments you may see people experiencing the same issue(' it's working now. not sure why'). So before looking upon any elaborate solution, just restart code.

Jupyter Notebook does not work fully in Pycharm

I am following these steps to run IPython in the Pycharm IDE. On pressing run button in any cell, I do get below pop-up window
According to the mentioned guide (given link), On pressing OK, I should get following message
But, I am not getting any type of message/response. So, I am not able to see the output of any cell contents. Does anyone know why I am not getting any response on selecting OK?
System Information:
OS: MAC OS 10.10.3
Python: 2.7.10 using Anaconda 2.3.0
Ipython: 4.0.0
Pycharm: pycharm community addition 2016.2
I solved following:
First I followed the reply to the issue jupyter-notebook No such file or directory: 'conda', in short you should do:
conda update nb_conda nb_conda_kernels nb_anacondacloud
Then, I ran my jupyter notebook in my browser. I took note where the Jupyter notebook was running, i.e.
The Jupyter Notebook is running at: http://localhost:8888/
Then I started a new Jupyter Notebook in PyCharm2016.2.2, and when it asked about the Jupyter Notebook URL I changed the default http://127.0.0.1:8888 to http://localhost:8888/
and finally it worked.
For the PyCharm Jupyter notebooks, to see results you need to open up a jupyter notebook.
The reason why you don't just do all your code in Jupyter Notebooks is because Pycharm helps with LaTex integration and many more functions.
According to this answer:
Jupyter notebook server not working with latest PyCharm 2017.2 update. How do I solve this?
You need a package named ”notebook“. I had the same issue and I solved it by installing the package.

Categories

Resources