Master Jupyter Notebook: Change Directory, Browser, Password, and Themes
This guide walks Jupyter Notebook beginners through essential configuration steps—including altering the default working directory, setting a preferred browser, securing the notebook with a password, installing useful extensions, and customizing the notebook’s appearance—empowering a smoother, more personalized Python workflow.
Jupyter Notebook is a versatile web application that supports Python and many other languages, enabling data processing, statistical modeling, visualization, machine learning, teaching demos, and web scraping.
This article focuses on practical solutions for common Jupyter setup issues, such as changing the default directory and browser, setting a login password, installing extensions, and customizing the notebook style.
What is a Jupyter configuration file?
The configuration file allows you to modify various Jupyter settings. The file jupyter_notebook_config.py does not exist by default and must be generated.
Generate it by running: jupyter notebook --generate-config The file is created in C:\Users\Administrator\.jupyter\.
1. Change default working directory
Jupyter’s default working directory is C:\Users\Administrator\, which is often inconvenient. Edit the configuration file to set a new directory.
Open jupyter_notebook_config.py with a text editor.
Search for c.NotebookApp.notebook_dir and remove the leading #.
Set the desired path, e.g., c.NotebookApp.notebook_dir = "E:\\jupyter_notebook", using double backslashes.
Modify the shortcut target in the Windows Start menu to remove the trailing %USERPROFILE%/.
2. Change default browser
To launch Jupyter in your preferred browser (e.g., Chrome), locate the full path to chrome.exe and add the following to the configuration file:
import webbrowser
webbrowser.register('chrome', None, webbrowser.GenericBrowser('C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'))
c.NotebookApp.browser = 'chrome'Save the file and restart Jupyter.
3. Set login password
Open jupyter_notebook_config.py and find c.NotebookApp.allow_password_change, set it to False, and remove the comment symbol.
Run jupyter notebook password in the command line and follow the prompts to create a password.
Locate the generated JSON file in the .jupyter folder, copy the hashed password.
Insert the hash into the configuration file as c.NotebookApp.password = u'sha1:...' and save.
4. Install extensions
Install nbextensions: pip install jupyter_contrib_nbextensions Install JavaScript and CSS files: jupyter contrib nbextension install --user Install the configurator: pip install jupyter_nbextensions_configurator Restart Jupyter Notebook to see the nbextensions tab.
5. Modify notebook style
Install the theme tool: pip install jupyterthemes List available themes: jt -l Apply a theme (e.g., chesterish): jt -t chesterish Restore the default theme: jt -r Additional options allow changing fonts, widths, and other style parameters.
Summary
Jupyter Notebook is a powerful and enjoyable tool; mastering its configuration—directory, browser, password, extensions, and themes—greatly enhances productivity and user experience when working with Python.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Python Crawling & Data Mining
Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
