Clear or hide old remote kernel connections and use local (or selected interpreter) kernel by default - visual-studio-code

Using Windows 10, remote server is Linux
I had set up VSCode to be able to use kernels from a JupyterHub server (there are two in the image, "Python 3" and "venv"), but have since found I prefer using the Remote-SSH extension to develop directly on the server. I want to get rid of this long list of kernels available when editing a notebook or interactive .py file in VSCode:
It's additionally annoying because the selected kernel defaults to the first kernel in the list, which doesn't have all the dependencies I need, so I always see an import error. This environment is managed by my IT so I can't just alter it or install what I need there.
I would love to just get rid of the remote kernels entirely and just use local kernels (shown by clicking the Connect to Local Kernels option in the image), or at least show the local kernels by default. Ideally, the selected Python interpreter would always be automatically selected as the kernel.
Things I've tried:
Deleting the remote URI > Jupyter: Specify Jupyter Server for Connections. VSCode let me delete all but one URI.
> Jupyter Filter Kernels doesn't save my selections half the time, and it never changes jupyter.kernels.filter in settings.json, so this has never had an effect on the kernels that are listed.
Reinstalling the Jupyter extension
Reinstalling the Jupyter extension and deleting it's C:\myuser\.vscode\extensions folder
Searching for other places this connection data might be stored but found nothing

Related

Why do my internal hyperlinks not work in my notebook when creating them remotely?

I have quite a large jupyter notebook I'm working on in VScode, while using the high performance computing facility (connected through SSH).
I am trying to create some internal hyperlinks so I can jump from my table of contents to a specific section in the notebook. However, this does not work.
Code I'm using to create the link:
[Summary](#Summary)
some other cells
## Summary
It does create a link, but clicking on it does not work in VScode. This one keeps me right at the top of the notebook, other links to sections further down bring me to seemingly random cells down my file. Also, when opening the notebook in Github, clicking the link brings me back to the folder where my notebook is located.
The same construction does work both in a local jupyter instance, and in vscode, when not connected to the HPC.
One difference I can think of is that I use miniconda on the HPC, and the full anaconda installation locally.
Are the links not supported in miniconda? Or is it something else?

Missing Jupyter Notebook Kernels in VSCode

I have multiple people working on the same AWS EMR cluster to run some Spark jobs. This is being done through Jupyter Notebooks which are created/modified using the Jupyter extension installed on a SSH Target through vscode. The modules are installed on the base conda environment that is included with the /emr/notebook-env/. Some people can see the correct kernel that is associated with the base conda environment in their vscode window when working on notebooks. However, some don't see this kernel as an option. How do I make sure that everyone's vscode lists the appropriate kernel when they are creating new notebooks or modifying existing notebooks?
Another potential reason this could happen is that the Jupyter exentsion of VSCode is not installed.
To add the Jupyter extension for VSCode, search for it by clicking extensions icon in lefthand toolbar, then searching for Jupyter and installing.
The user having the issue had to update their vscode and that fixed the issue

Setting up jupyter kernel in remote VSCode notebook

I am trying to run some notebooks in my virtual environment in the VSCode (remotely connected). I install the venv as usual via python3 -m venv <venv-name>, activate it and install all the needed modules. When I run which ipython I get the one from the venv so I install the kernel via ipython kernel install --name "<name>" --user and it is successfully created in ~/.local/share/jupyter/kernels/ directory and the kernel.json points to the venv python. Then I open the VSCode and select both the Python: Select Interpreter and Jupyter: Select Interpreter to start Jupyter server to point to the virtual environment's python, sth. like .../<venv-name>/bin/python3.
However, when I try to run the cell it wants me to select kernel (I can also do it myself in the upper right corner of the VSCode), but my newly created kernel is not there. There are only two (same) ones from usr/bin/python.
It is really strange since twice in two days my kernel magically appeared for one notebook and worked as desired, but when I opened a new notebook, my kernel was gone again. I tried to remove/reinstall kernels, venvs, VSCode's Python and Jupyter extensions but nothing helped. Any suggestions?
For now, I start the kernel in remote command-line via jupyter notebook --no-browser --ip=<ip> and then insert the connection link to Jupyter Server in the bottom right corner of the VSCode status bar but am wondering if there is an easier way since all the stuff (except VSCode) is on a remote machine?
This way is not easy. You can set up Jupyter Kernel easily.
Firstly, using ssh to connect to the remote server.
Secondly, open Command Palette (⇧⌘P) and enter Python: Select Interpreter, you can directly connecting to remote kernel.
resource: https://code.visualstudio.com/docs/datascience/jupyter-notebooks

Can I add a remote Python interpreter (via SSH) to a local VSCode environment (i.e. a hybrid local/remote SSH setup)?

I have VSCode set up with the "Remote - SSH" extension, and I am able to run a local VSCode window as the face of a full remote environment. Really cool.
However, I would also like to be able to set up a local VSCode environment which loads files from my local filesystem but runs them on a remote Python interpreter (via an SSH connection).
I am hoping I can run all the regular interactive Python REPL stuff using the remote kernel (e.g. show variables, etc). It seems like I should be able to somehow add a remote kernel and then select it via "Python: Select Interpreter", but I can't figure out how.
In the past I was able to configure such a setup in JupyterLab using the "remote_ikernel" package.
Is this possible in VSCode? I've found tons of documentation on the full remote setup, but haven't located information on this hybrid kind of set up.
I found a related bug report which discusses mixing local and remote filesystems (not interpreters).
I suspect that the same difficulties it describes for filesystems may be similar reasons for why local files can not be easily fed into remote interpreters.
The full thread is here for reference:
https://github.com/microsoft/vscode-remote-release/issues/706
The specific quote:
Having a mixed workspace would require that a workspace extension can be active both locally and remotely. Currently an extension can only be active once, either locally or remotely. So this is currently not possible and we have no plans to support this.
The recommendation is to have separate windows open for the local and remote workspace.
So it sound like this is a feature that is not currently supported.

Changing Jupyter Notebook start location [Win 7 Enterprise]

I am trying to change the default Jupyter Notebook start directory on my Windows 7 Enterprise machine. Other answers have suggested changing the "Start In" field found through Right-click>Properties>Shortcut on the Jupyter program in my Start menu, however this doesn't have any effect. When I change this field to my desired directory and try running the program it still opens in the default directory, when I recheck the "Start In" field it is the same as whatever I had changed it to so it looks like it isn't being changed back by Windows, rather it's being disregarded entirely. For reference the default directory is at P:\ which is not a local directory and is hosted on my company servers, and I am trying to change the Jupyter startup directory to C:.
I'm sure the path is correct - I've tried a few different ones and they are working with autocomplete. I should mention this is a locked down corporate machine and I have to run Jupyter as administrator or else it exits immediately. I do have elevated rights and have checked the user permissions on Jupyter. This is using the Jupyter that comes as default with the current Python 3.5 distribution of Anaconda - I have also tried reinstalling the whole Anaconda package and I'm currently working with a fresh default install.
I am wondering if there is perhaps a way through changing the startup script that is run when you execute the program?
Found the solution - go to your Anaconda install directory (for me this was C:\Anaconda3) and open the file cwp.py in a text editor. Change the line
os.chdir(documents_folder)
to
os.chdir("C:\\my\\path\\here").