Skip to content

command_line_usage

While JupyterLab and Jupyter Notebook provide rich web-based interfaces, you can also interact with IPython and manage Jupyter components directly from your terminal using command-line options.

To start the enhanced IPython terminal session, simply type:

ipython

You can also execute scripts or commands directly:

  • ipython my_script.py: Executes the script and exits.
  • ipython -i my_script.py: Executes the script, then enters an interactive IPython session with the script’s namespace loaded.
  • ipython -c "print('Hello'); import numpy as np; print(np.__version__)": Executes the given command string.
  • ipython -m my_module: Runs a library module as a script (similar to python -m).

To start the modern JupyterLab interface:

jupyter lab

Common options include:

  • --no-browser: Starts the server without automatically opening a web browser.
  • --port=XXXX: Specifies the port number to use (default is 8888).
  • --ip=0.0.0.0: Makes the server accessible from other machines on the network (use with caution, consider security implications like setting a password).
  • --notebook-dir=/path/to/start: Specifies the root directory for the file browser.
  • --ServerApp.token='' and --ServerApp.password='' : Disable token authentication (useful in secure environments or when using other auth methods, like JupyterHub).
# Start JupyterLab on port 9999 without opening the browser
jupyter lab --no-browser --port=9999

To start the classic Jupyter Notebook interface:

jupyter notebook

It accepts many of the same options as jupyter lab (e.g., --no-browser, --port, --ip, --notebook-dir).

IPython provides subcommands for managing its configuration:

  • ipython profile create <profilename>: Creates a new configuration profile.
  • ipython profile list: Lists available profiles.
  • ipython locate: Shows the path to the IPython configuration directory.
  • ipython locate profile <profilename>: Shows the path to a specific profile directory.
  • ipython kernel install [--user] [--name=<kernelname>] [--display-name=<displayname>]: Installs a kernel spec for the current environment, making it available in Jupyter.
  • jupyter kernelspec list: Lists all installed Jupyter kernels.
# Create a profile for project 'myproj'
ipython profile create myproj
# Start ipython with this profile
ipython --profile=myproj
# Install the current python environment as a kernel named 'py310-myenv'
jupyter kernel install --user --name=py310-myenv --display-name="Python 3.10 (My Env)"
  • jupyter --paths: Shows various Jupyter configuration and data paths.
  • jupyter nbconvert: Converts notebooks to other formats (HTML, PDF, Python script, etc.). jupyter nbconvert --to script my_notebook.ipynb
  • jupyter run my_notebook.ipynb: Runs a notebook from the command line.
  • jupyter console: Starts a terminal-based Jupyter console connected to a kernel.
  • jupyter qtconsole: Starts a richer Qt-based Jupyter console.

Refer to the help options for each command (e.g., ipython --help, jupyter lab --help, jupyter nbconvert --help) for a full list of available options and subcommands.