How do I add a module path to a IPython Notebook?
-
I have a folder in my project, with ipython notebooks. I need to render them and import other packages in the project that aren't part of the sys.path in the notebook. Different notebooks will import different packages from different places and I don't want/can't add all of them to the global sys.path. Also, I don't want to have to show the sys.path hack in the notebook itself. Do you know of any, per notebook, configuration I can use?
-
Answer:
If by "sys.path hack" you mean appending or inserting to sys.path on notebook initialization, this is not a hack - https://docs.python.org/3.4/tutorial/modules.html#the-module-search-path. About not showing it in the notebook, you can execute JavaScript from markdown blocks; for example, add this to your introduction text block: <script> $(document).ready(function () { $('.code_cell:first').hide(); }); </script> https://gist.github.com/psionski/800775ee36120ea9f3b7, result http://nbviewer.ipython.org/gist/psionski/800775ee36120ea9f3b7 This will hide the first code block from the notebook, whatever that may be. Set your paths in the first block, then do the imports in another block so they are visible to the readers.
Vladislav Zorov at Quora Visit the source
Other answers
Not sure if this would suit your needs, but you could use different IPython profiles, and modify sys.path in a profile-specific startup file.
Joe Pallas
Related Q & A:
- How can I add a slideshow to my site?Best solution by webstarts.com
- How can I add a clickable link to a question or answer on yahoo?Best solution by Yahoo! Answers
- How can I add a picture to a video?Best solution by Answerbag.com
- How do I add a photo to a Wikipedia page?Best solution by en.wikipedia.org
- How do I add a photo to a question?Best solution by Answerbag.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.