In IPython, I can load a custom extension using simple command:
%load_ext physics
This will load the file ~/.ipython/extensions/physics.py
.
How can I tell IPython to load the extension automatically on startup?
I have added the line to /.ipython/profile_default/startup/import.py
, but that does not work:
from numpy import *
%load_ext physics
When I start IPython, I get folowing error:
File "~/.ipython/profile_default/startup/import.py", line 17
%load_ext physics
^
SyntaxError: invalid syntax
autoreload reloads modules automatically before entering the execution of code typed at the IPython prompt. The module was reloaded without reloading it explicitly, and the object imported with from foo import ... was also updated.
Autoreload is a simple python script to watch a directory for changed files and restarts a process when the change is detected. autoreload. #!/usr/bin/env python.
An IPython extension is an importable Python module that has a couple of special functions to load and unload it. Here is a template: # myextension.py def load_ipython_extension(ipython): # The `ipython` argument is the currently active `InteractiveShell` # instance, which can be used in any way.
IPython (Interactive Python) is a command shell for interactive computing in multiple programming languages, originally developed for the Python programming language, that offers introspection, rich media, shell syntax, tab completion, and history.
From the IPython documentation:
Using extensions
To load an extension while IPython is running, use the
%load_ext
magic:In [1]: %load_ext myextension
To load it each time IPython starts, list it in your configuration file:
c.InteractiveShellApp.extensions = [ 'myextension' ]
Hope that helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With