Best way to run Julia code in an IPython notebook (or Python code in an IJulia notebook)

Run Julia inside an IPython notebook Hack In order to run Julia snippets (or other language) inside an IPython notebook, I just append the string ‘julia’ to the default list in the _script_magics_default method from the ScriptMagics class in: /usr/lib/python3.4/site-packages/IPython/core/magics/script.py or /usr/lib/python2.7/site-packages/IPython/core/magics/script.py. Example: # like this: defaults = [ ‘sh’, ‘bash’, ‘perl’, ‘ruby’, ‘python’, ‘python2’, … Read more

execute Bash command from IPython

Fernando Perez, creator of IPython, suggests this: In [1]: %%bash . ~/.bashrc <my_fancy_bash_function> <function_argument> This works on the current stable version (0.13.2). He admits that’s a bit clunky, and welcomes pull requests. . .

ipython: how to set terminal width

You can see your current line width with numpy.get_printoptions()[‘linewidth’] and set it with numpy.set_printoptions(linewidth=160) Automatically set printing width If you’d like the terminal width to be set automatically, you can have Python execute a startup script. So create a file ~/.python_startup.py or whatever you want to call it, with this inside it: # Set the … Read more

How to display line numbers in IPython Notebook code cell by default

(For Jupyter 4+) In the latest Jupyter versions, they have documented the place to make config changes. So basically, in the Jupyter update, they’ve removed the concept of profiles, so the custom.js file location is now .jupyter/custom/custom.js, depending on where your .jupyter folder is. So if you don’t have a custom folder or the custom.js … Read more

How can I launch ipython from shell, by running ‘python …’?

To start IPython shell directly in Python: from IPython import embed a = “I will be accessible in IPython shell!” embed() Or, to simply run it from command line: $ python -c “from IPython import embed; embed()” embed will use all local variables inside shell. If you want to provide custom locals (variables accessible in … Read more

Where should I place my settings and profiles for use with IPython/Jupyter 4.0?

First of all, check what’s in your ~/.jupyter/ folder. Some of the comments under the question mention you have a file named “MIGRATED” that contains only a timestamp. If you are in this state, run the command: jupyter notebook –generate-config which will create a new file ~/.jupyter/jupyter_notebook_config.py. If you already have this file, you don’t … Read more