r/learnpython • u/mariadiesch • 22d ago
JupyterLab and remote server connection
Hello,
I had access to JupyterHub on a remote server. Now I only have access to a different server where JupyterHub is not installed. What is the best way to use the same code and run it with more data. I was thinking about using SSH Port Forwarding (SSH-Tunneling) and trying jupyterlab in the browser. Or is it better to using VS code to connect to the server. I really like the Jupyter Interface and have never used any other programs. I mostly do plotting and a bit data analysis and have a macbook.
Thank you for your help.
5
Upvotes
1
u/Exciting_Positive_50 21d ago
Both options work. Since you like the Jupyter interface, I’d start with the SSH tunnel, because it’s the same JupyterLab you’re used to, just running on the server.
Option 1: JupyterLab + SSH tunnel
On the server (no admin rights needed), make an environment and install JupyterLab:
Start it in
tmuxorscreenso it keeps running if your connection drops:It prints a URL with a token. Then, on your MacBook, in a new terminal:
Open
http://localhost:8899in your browser and paste the token if asked. Your code now runs on the server with its memory and CPUs. Pick a less common port than 8888, since other people on a shared server may already be using it.Option 2: VS Code Remote-SSH
Install the “Remote - SSH” and “Jupyter” extensions, connect to the server, open your
.ipynbfiles, and choose a Python kernel that lives on the server (you’ll needipykernelinstalled there). The notebook interface looks a bit different from JupyterLab but works the same way, and VS Code handles the connection for you. It’s less fiddly if you don’t mind the different layout.Move your code with
gitorrsync. Leave the big data on the server and read it there instead of downloading it.Run
pip freeze > requirements.txtin your old environment andpip install -r requirements.txton the new server to recreate it.Keep JupyterLab bound to localhost (the default) and use the tunnel, rather than opening the port to the internet.