How to import "orange" in ipython notebook?

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

Was this solution helpful to you?

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:

Just Added Q & A:

Find solution

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.