When I start the Jupyter Notebook, I changed ipython_config.py in my ipython profile to automatically load numpy as np :
c.InteractiveShellApp.exec_lines = [ 'import numpy as np', ]
This works great. When I start the laptop, in the first cell I can immediately call the entire numpy library via np. . However, if I share this laptop using the gist method or some other method, this import is not explicitly displayed. This is suboptimal because it makes clear reproducibility impossible.
My question is: Is it possible to automatically fill the first cell of a new laptop with the code that I import? (Or another similar way to document the import that occurs for a laptop).
I would be fine with removing the exec_lines option and pre-populating the code that I have to run myself or some other solution that falls into the main idea: explicit reproducibility of the code that I initially import into the notebook.
Edit
A remote answer that may be useful for people landing here: I found jupyter_boilerplate , which as an installable extension for a laptop βAdds a custom menu item for Jupyter (IPython) to insert snippets of template codeβ - will make it easy to create a snippet of source code that can to be filled.
Sidenote MLavoie because "comments are disabled for deleted / blocked messages / reviews"
Yes, you are right that:
While this link can answer the question, itβs better to include the main parts of the answer here and provide a link for reference. Response links may become invalid if the linked page changes. - From Review - MLavoie Jun 8 '16 at 17:27
But you will notice that this is a widget that needs to be installed, so there is no corresponding code here. Incorrectly delete the above answer.
source share