Spaces:
Sleeping
Sleeping
# 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() | |