We have recently moved to a JupyterLab Server from another IDE. We are trying to get VS Code hooked up so that we can code in it rather. After much struggle, we got VS Code to connect to our remote JupyterLab server. On the status bar in the bottom, it shows
However, as soon as we connect to the JupyerLab server, all the 'run' buttons on screen disappears.
We are getting no support from our IT and have to figure it out ourselves.
A colleague suspects that it (VS Code) is not picking up the python kernel from the server. How do we go about selecting it? or pointing to it?
An additional question, how do we see and browse the folders on the JupyterLab server in VS Code?
Appreciate any assistance
I think the problem is that you didn't really connect to the remote server.
Install Remote-SSH extension. Then you can see the button on the bottom left. Click and you can connect to your service and view your folder.
You can read document about Remote-SSH for more details/
Connect to a remote Jupyter server.
According to the document about jupyter, you have to do the following steps:
Open the Kernel Picker button on the top right-hand side of the notebook (or run the Notebook: Select Notebook Kernel command from the Command Palette).
Select the Existing Jupyter Server option to connect to an existing Jupyter server.
To connect to an existing server for the first time, select Enter the URL of the running Jupyter server.
When prompted to Enter the URL of the running Jupyter server, provide the server's URI (hostname) with the authentication token included with a ?token= URL parameter. (If you start the server in the VS Code terminal with an authentication token enabled, the URL with the token typically appears in the terminal output from where you can copy it.) Alternatively, you can specify a username and password after providing the URI.
Related
I want to run local code using local data on a remote server and get back execution results back to my Jupyter notebook cells.
Not usual scheme "run Jupyter notebook remotely, connect to remote notebook via ssh tunneling" but more sophisticated via custom remote kernel which I may choose from the kernel list, and run local code on remote server seamlessly.
Some packages (like this -- https://pypi.org/project/remote-kernel) mention that it is possible, but look dated and come with limited usage instructions.
Anyone knows how to implement this? If so, be as more detailed as possible, thanks!
Suppose I have a Google Colab Notebook in an address like below:
https://colab.research.google.com/drive/XYZ
I want to keep it running for 12 hours, however, then again I want to turn my computer off. As a solution, I can connect to our Lab's server via ssh. The server is running all the time. I would like to know if it's possible that I load and run the notebook there?
I found a solution to connect to a Google Colab Session via ssh (colab_ssh package), but it again needs a running Colab Session.
I also tried to browse the link with lynx, but it needs login and this isn't supported by this browser.
Yes, it is possible. You would first need to download your colab notebook as an .ipynb file, then copy it to your server. Then, you can follow one of the guides on how to connect to a remotely running jupyter notebook session, like this one. All you need is the jupyter notebook software on your server, and an ssh client on your local computer.
Edit: I forgot to mention this: To keep your session alive even after closing the ssh connection, you can use tools like screen. The link provides more detailed explanation, but the general idea is that after connecting to your server, first you need to create a session like this:
screen -S <session_name>
which will create a new session and attach you to it (which is the term used when you are inside a session). Then, you can fire up your jupyter notebook here, and it will keep running even after closing the ssh connection. (You just have to make sure you don't kill the screen session using Ctrl+a followed by k)
Now, you have an indefinitely running jupyter notebook session on your server. You can connect to it via
ssh -N -f -L localhost:YYYY:localhost:XXXX remoteuser#remotehost
as mentioned in the first linked guide, use the browser to run a code cell on your jupyter notebook, and then turn off your laptop without worrying about interrupting your notebook session.
I'm trying to connect to a remote jupyter notebook.
Server-side actions:
I simply use jupyter notebook command that produces the following output:
http://localhost:8888/?token=c7a760ee5387de7d6a1cb797a0685a116621f8b3b5a1a5ba
I know that there's password authentication procedure as well. I set up the jupyter_notebook_config.py file. I changed the c.NotebookApp.password and c.NotebookApp.open_browser variables.
Client-side actions:
Since I'm using Putty I can copy/paste the HTTP address (with token) to a local browser. I get the following page:
Even though I'm using the token from the link (step 1) and password (step 2) I get the Invalid Credentials error.
There's a proxy server between the local machine and the server but I don't know how to account for that fact.
Update 11.10.2019
I decided to tweak some parameters in .jupyter/jupyter_notebook_config.py file. By sacrificing security I did away with token authentication by setting c.NotebookApp.token=''. I still get the Invalid credentials message.
jupyter_notebook_config.py which resides in .jupyter directory (in the home directory of the user) is created with jupyter notebook --generate-config. All of the options are commented out. You need to find c.NotebookApp.ip variable that must not be commented out and set its value to the IP of the server the Jupyter is running on. If you want to connect to that instance of Jupyter from another machine you need to find localhost:port webpage with a browser of your choosing. My answer assumes that you've forwarded the port you are using.
We are trying to execute bokeh server from a Windows Server. Everything looks fine. But when trying to reach the it from another device we get the following error in the web browser: "403: Forbidden".
Even though the bokeh server is executed allowing all ports and incoming IPs, we still get a message telling us that the host is not in the whitelist. This is the server output when executing bokeh and trying to reach it from another computer:
Every device is connected to local network.
I attach what we get when log level is in debug:
There is a difference in how shell quoting works between platforms. On Windows, you need to do
--host=*
with no quotes around the asterisk.
The issue I'm facing right now:
I deploy Python code on a remote host via SSH
the scripts are passed some arguments and must be ran by a specific user
the PyCharm run/debug configuration that I create connects through SSH via a different user (can't connect with the user that actually runs the scripts)
I want to remote debug this code via PyCharm...I managed to do all configuration, I just get permission errors.
Are there any ways on how I can run/debug the scripts as a specific user (like sudo su - user)?
I've read about specifying some Python Interpeter options in PyCharm's remote/debug configuration, but didn't manage to get a working solution.
If you want an easy and more flexible way to get into the PyCharm debugger, rather than necessarily having a one-click "play" button in PyCharm, you can use the debug server functionality. I've used this in situations where running some Python code isn't as simple as running python ....
See the Remote debug with a Python Debug Server docs for more details, but here's a rough summary of how it works:
Upload & install remote debugging helper egg on your server (On OSX, these are found under /Applications/PyCharm.app/Contents/debug-eggs)
Setup remote debug server run configuration: click on the drop-down run configuration menu, select Edit configurations..., hit the + button, choose Python remote debug.
The details entered here (somewhat confusingly) tell the remote server running the Python script how to connect to your laptop's PyCharm instance.
set Local host name to your laptop's IP address
set port to any free port that you can use on your laptop (e.g. 8888)
Now follow the remaining instructions in that dialog box: copy-paste the import and pydevd.settrace(...) statements into your code, specifically where you want your code to "hit a breakpoint". This is basically the PyCharm equivalent of import pdb; pdb.set_trace(). Make sure the changed code is sync'ed to your server.
Hit the bug button (next to play; this starts the PyCharm debug server), and run your Python script just like you'd normally do, under whatever user, environment etc. When the breakpoint is hit, PyCharm should drop into debug mode.
I have this (finally) working with ssh RemoteForward open, like so:
ssh -R 5678:localhost:5678 user#<remotehost>
Then start the script in this ssh session. The python script host must connect to localhost:5678 and of course your local pycharm debugger must listen to 5678
(or whatever port you choose)