File size: 1,402 Bytes
9445a1b
95d0316
9445a1b
 
f5f6658
9445a1b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# run_jupyterlab.py
import subprocess
import sys
import os

def launch_jupyterlab():
    """Launches JupyterLab programmatically on port 7860."""
    print("Attempting to launch JupyterLab on port 7860...")

    command = [
        sys.executable,
        "-m",
        "jupyterlab",
        "--no-browser", # Remove this line if you want it to open automatically in your browser
        "--port",
        "7860" # Changed the port to 7860 as requested
    ]

    # Optional: Uncomment and modify if you want to specify a working directory
    # command.extend(["--notebook-dir", "/path/to/your/notebooks"])

    try:
        print(f"Executing command: {' '.join(command)}")
        process = subprocess.Popen(command)
        
        print("\nJupyterLab launched! Check your terminal for the URL.")
        print("You should see a URL like 'http://localhost:7860/lab?token=...'")
        print("Copy and paste this URL into your web browser to access JupyterLab.")
        print("Keep this terminal window open while you are using JupyterLab.")

    except FileNotFoundError:
        print("Error: 'jupyterlab' command not found.")
        print("Please ensure JupyterLab is installed. You can install it with:")
        print("pip install jupyterlab")
    except Exception as e:
        print(f"An error occurred while launching JupyterLab: {e}")

if __name__ == "__main__":
    launch_jupyterlab()