Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8727779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:30:07+00:00 2026-06-13T08:30:07+00:00

I am trying to obtain the current NoteBook name when running the IPython notebook.

  • 0

I am trying to obtain the current NoteBook name when running the IPython notebook. I know I can see it at the top of the notebook. What I am after something like

currentNotebook = IPython.foo.bar.notebookname()

I need to get the name in a variable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:30:08+00:00Added an answer on June 13, 2026 at 8:30 am

    As already mentioned you probably aren’t really supposed to be able to do this, but I did find a way. It’s a flaming hack though so don’t rely on this at all:

    import json
    import os
    import urllib2
    import IPython
    from IPython.lib import kernel
    connection_file_path = kernel.get_connection_file()
    connection_file = os.path.basename(connection_file_path)
    kernel_id = connection_file.split('-', 1)[1].split('.')[0]
    
    # Updated answer with semi-solutions for both IPython 2.x and IPython < 2.x
    if IPython.version_info[0] < 2:
        ## Not sure if it's even possible to get the port for the
        ## notebook app; so just using the default...
        notebooks = json.load(urllib2.urlopen('http://127.0.0.1:8888/notebooks'))
        for nb in notebooks:
            if nb['kernel_id'] == kernel_id:
                print nb['name']
                break
    else:
        sessions = json.load(urllib2.urlopen('http://127.0.0.1:8888/api/sessions'))
        for sess in sessions:
            if sess['kernel']['id'] == kernel_id:
                print sess['notebook']['name']
                break
    

    I updated my answer to include a solution that “works” in IPython 2.0 at least with a simple test. It probably isn’t guaranteed to give the correct answer if there are multiple notebooks connected to the same kernel, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm essentially trying to obtain a resultset with each employee's current title. I'd like
I am trying to obtain the current user's SharePoint group name that they belong
Does anyone know how to obtain the path to the current directory when running
I am trying to obtain the value part of this syntax: [name:value] I got
Im trying to obtain the IP address of the user, current domain, and full
I am trying to obtain the module GUIDs from the current process by enumerating
Trying to parse xml to text I got something like this, INPUT FILE <Item
I'm trying to obtain the current week for date comparison in SQLite. I have
I'm trying to obtain my current location via GPS, but nothing seems to work,
I've run into some strange behaviour when trying to obtain the current stack pointer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.