So I did a fresh new installation (anaconda + Python 2.7) for other reasons
and now the code I used to get the file path of the currently running
notebook does not work anymore. This is annoying to say the least.
This is my code, screapped together from various places. First, I find what
the port of the notebook server is:
%%javascript
var nb = Jupyter.notebook;
var port = window.location.port;
//nb.kernel.execute("NB_NAME = '" + nb.notebook_name + "'");
nb.kernel.execute("NB_Port = '" + port + "'");
Then, I get the file path:
# Get file path of this notebook
connection_file_path = kernel.get_connection_file()
connection_file = os.path.basename(connection_file_path)
kernel_id = connection_file.split('-', 1)[1].split('.')[0]
sessions =
json.load(urllib2.urlopen('http://127.0.0.1:'+NB_Port+'/api/sessions'))
for sess in sessions:
if sess['kernel']['id'] == kernel_id:
nb_rel_path = (sess['notebook']['path'])
break
res = !echo ~
nb_path = os.path.join(res[0],nb_rel_path)
nb_path
nb_dir,nb_filename = os.path.split(nb_path)
Well, now the line
sessions =
Fails with
ValueError: No JSON object could be decoded
Any suggestions? TIA.
--
You received this message because you are subscribed to the Google Groups
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jupyter/faa43320-189a-4575-8b94-59e32ed48109%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.