import a function from another .ipynb file

You’ll want to use the ipynb package/module importer. You’ll need to install it: pip install ipynb. Create a Notebook named my_functions.ipynb. Add a simple function to it. def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) Then, create a second IPython Notebook and import this function with: from ipynb.fs.full.my_functions import factorial … Read more

Link Conda environment with Jupyter Notebook

For Anaconda I suggest you a much easier and proper solution; just give a look at the nb_conda_kernels package. It allows you to “manage your conda environment-based kernels inside the Jupyter Notebook”. Is should be included since Anaconda version 4.1.0, otherwise simply use conda install nb_conda Now you should be able to manage all direcly … Read more

How can I play a local video in my IPython notebook?

(updated 2019, removed unnecessarily costly method) Just do: from IPython.display import Video Video(“test.mp4”) If you get an error No video with supported format or MIME type found, just pass embed=True to the function: Video(“test.mp4”, embed=True). Or if you want to use the HTML element: from IPython.display import HTML HTML(“”” <video alt=”test” controls> <source src=”test.mp4″ type=”video/mp4″> … Read more

Running Jupyter with multiple Python and IPython paths

This is fairly straightforward to fix, but it involves understanding three different concepts: How Unix/Linux/OSX use $PATH to find executables (%PATH% in Windows) How Python installs and finds packages How Jupyter knows what Python to use For the sake of completeness, I’ll try to do a quick ELI5 on each of these, so you’ll know … Read more

Adding line breaks in ipython

Been suffering this problem for a while. I just found that when using Ctrl-qCtrl-j (That’s lowercase Q, J, no need to hold the shift key) will add a linefeed to an existing IPython edit session. for li in some_list: print(li) Moving the cursor after the colon and pressing Ctrl-qCtrl-j for li in some_list: print(li) IPython: … Read more

How to get ipywidgets working in Jupyter Lab?

JupyterLab now prefers a model where arbitrary javascript is no longer allowed to be embedded in a cell’s output, which is how many interactive Jupyter Notebook modules used to work. They now ask that modules with interactivity create a JupyterLab extension. ipywidgets provides @jupyter-widgets/jupyterlab-manager extension which satisfies this requirement. When using ipywidgets 7.6 or newer … Read more