Specify hostname to jupyter notebook when running on remote server - python

I'm running a notebook on a remote server, to which I connect from my local machine via browser. One slight annoyance I have is it prints this on start:
Serving notebooks from local directory: /home/xxxxxxx
0 active kernels
The Jupyter Notebook is running at:
http://(friendly or 127.0.0.1):8888/
Where friendly is the friendly name of the host. The FQDN of the host is actually friendly.x.y.z.com. I would like it to print this:
The Jupyter Notebook is running at:
http://friendly.x.y.z.com:8888/
so that the URL is directly clickable from the console. Is there a config option I can pass somewhere to do that in jupyter notebook to explicitly specify the hostname I want displayed?
To be clear, http://friendly.x.y.z.com:8888/ resolves correctly in the browser despite the above message.

You should first generate the config file:
jupyter notebook --generate-config
Then using the config file you can set the custom URL by editing the config file ~/.jupyter/jupyter_notebook_config.py changing the following line:
c.NotebookApp.custom_display_url = 'http://friendly.x.y.z.com:8888'
So when you start the server it will show this URL concatenated with the token.

Related

In PyCharm the Jupyter Server tool window to preview server's configuration details gives nothing

I use PyCharm Professional and I am trying to launch Jupyter Notebook inside PyCharm IDE.
I followed the official instructions Manage Jupyter notebook servers.
I installed Jupyter and configured python 3.8 interpreter using virtual environment. I do not use conda.
When I run the first cell "Starting Jupyter Server" message is shown on the Jupyter top bar. I now that I have to insert Jupyter password or activation token for the server.
When I run command inside PyCharm terminal it gives me only the address:
jupyter notebook list
Currently running servers:
http://localhost:8888/
As officials say here must be shown authentication token for the server, but it is missing.
So, where I can find this token to enter the Jupyter Server and see other server's configuration details?
I have just found the answer by myself.
I have Jupyter configuration already in the folder ~/.jupyter/jupyter_notebook_config.py where the password and other parameters are set. So, to enter the server all I had to do is to enter the password which I set on my own in the above configuration file in the past.

How to maintain .ipynb running in the background with VSCode?

I have installed jupyter-related plugins in VS Code. While I close the VS Code, the GPU memory is cleared. I can't use jupyter like the traditional method in the browser.
I changed the jupyter to remote with localhost: port in VS Code, the Jupyter: Server Remote displayed in the button of VS Code GUI.
Steps:
The remote jupyter notebook is running in the tmux with & bash option.
Add port forward in VSCode.(maybe unnecessary)
Ctrl + Shift + P and search "Jupyter: Specify Jupyter Server for connections".
Add URL with the token.
Run a ipynb file and nvidia-smi to see the usage of GPU.
Close the VSCode, the GPU memory is clear.
When you use remote mode, the code runs in the server instead of the local computer.
Please operate again according to the documentation.
Select the Jupyter Server: local button in the global Status bar or run the Jupyter: Specify local or remote Jupyter server for connections command from the Command Palette (Ctrl+Shift+P).
When prompted to Pick how to connect to Jupyter, select Existing: Specify the URI of an existing server.
When prompted to Enter the URI of a Jupyter server, provide the server's URI (hostname) with the authentication token included with a 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

How to use JupyterLab in Visual Studio Code

is there a way to use JupyterLab in VS Code? I know that VS Code provides the Jupyter Notebook extension. However, I need to connect to another server remotely......
Any guidance will be appreciated!
You can offload intensive computation in a Jupyter Notebook to other computers by connecting to a remote Jupyter server. Once connected, code cells run on the remote server rather than the local computer.
To connect to a remote Jupyter server:
Select the Jupyter Server: local button in the global Status bar or
run the Jupyter: Specify local or remote Jupyter server for
connections command from the Command Palette (Ctrl+Shift+P).
When prompted to Pick how to connect to Jupyter, select Existing:
Specify the URI of an existing server.
When prompted to Enter the URI of a Jupyter server, provide the
server's URI (hostname) with the authentication token included with
a 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.
For guidance about securing a notebook server, refer to the Jupyter documentation.

VSCode remote Jupyter Notebook - Open an existing notebook in a specific folder on Jupyter Notebook remote server

I can connect to a remote Jupyter Notebook server with a token from VSCode through the "Python: Specify Jupyter server URI" command from the Command Palette.
However, I didn't find a way to do 2 things:
Open an existing Notebook on the remote Jupyter Notebook server.
Specify a folder to connect to, where my existing notebook resides in the remote server.
Is there a way of doing it?
Currently, VSCode doesn't support this functionality. See this issue: https://github.com/microsoft/vscode-python/issues/8161

unable to run jupyter within pycharm

D:\Python\python.exe "D:\PyCharm 2018.2.1\helpers\pycharm\pycharm_load_entry_point.py" notebook --no-browser --ip 127.0.0.1 --port 8886 --port-retries=0
[TerminalIPythonApp] WARNING | Subcommand `ipython notebook` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter notebook` in the future
[W 17:58:52.576 NotebookApp] Terminals not available (error was No module named 'winpty.cywinpty')
[I 17:58:52.579 NotebookApp] Serving notebooks from local directory: D:\Python projects\Projects
[I 17:58:52.579 NotebookApp] The Jupyter Notebook is running at:
Whenever I run a x.ipynb file it returns the error msg above, i can only access jupyter in browser.
How can I run it within pycharm??
You can use PyCharm as an IDE alternative for editing Jupyter notebooks in a browser, but it won't run a notebook server for you automatically. You can simply open *.ipynb file in PyCharm and it opens with a dedicated notebook editor. When you run a cell for the first time, it is going to ask you about the url of a running notebook, like http://localhost:8888/?token=<token>
You can get this url by running the following in a console:
jupyter notebook list
Running a notebook server is a separate thing. You can do it externally or use a built in 'Jupyer Notebook' run template (via 'Run...' menu'). When you start a server from inside PyCharm this way, you will get your notebook url in a run console.

Categories

Resources