Instead of
from IPython
import embed
embed()
Use this
from IPython.frontend.terminal.ipapp
import TerminalIPythonApp
app = TerminalIPythonApp.instance()
app.initialize(argv = [])
app.start()
You can run python shell.py
In[1]: % autoreload 2
In[2]:
autoreload reloads modules automatically before entering the execution of code typed at the IPython prompt.,Reloading Python modules in a reliable way is in general difficult, and unexpected things may occur. %autoreload tries to work around common pitfalls by replacing function code objects and parts of classes previously in the module with new versions. This makes the following things to work:,Methods and properties of classes are upgraded on reload, so that calling ‘c.foo()’ on an object ‘c’ created before the reload causes the new code for ‘foo’ to be executed.,IPython extension to reload modules before executing user code.
In[1]: % load_ext autoreload
In[2]: % autoreload 2
In[3]: from foo
import some_function
In[4]: some_function()
Out[4]: 42
In[5]: # open foo.py in an editor and change some_function to
return 43
In[6]: some_function()
Out[6]: 43
01 Oct 2019 6 min read
import importlib
importlib.reload(my_module)
% run my_file.py # You can even skip the ".py" extension: % run my_file
exec(open("./my_file.py").read())
% load_ext autoreload
% autoreload 2
So whether Magics are available is a decision that is made by the kernel developer on a per-kernel basis.,The following magic command give direct insight in what commands are available:,Magics for Python are provided by the IPython kernel. Every language used in a JupyterLab environment can have other magic command., © Copyright 2021, BM-Support.org - Maikel Mardjan. This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
% lsmagic
Available line magics: % alias % alias_magic % autoawait % autocall % automagic % autosave % bookmark % cat % cd % clear % colors % conda % config % connect_info % cp % debug % dhist % dirs % doctest_mode % ed % edit % env % gui % hist % history % killbgscripts % ldir % less % lf % lk % ll % load % load_ext % loadpy % logoff % logon % logstart % logstate % logstop % ls % lsmagic % lx % macro % magic % man % matplotlib % mkdir % more % mv % notebook % page % pastebin % pdb % pdef % pdoc % pfile % pinfo % pinfo2 % pip % popd % pprint % precision % prun % psearch % psource % pushd % pwd % pycat % pylab % qtconsole % quickref % recall % rehashx % reload_ext % rep % rerun % reset % reset_selective % rm % rmdir % run % save % sc % set_env % store % sx % system % tb % time % timeit % unalias % unload_ext % who % who_ls % whos % xdel % xmode Available cell magics: % % ! % % HTML % % SVG % % bash % % capture % % debug % % file % % html % % javascript % % js % % latex % % markdown % % perl % % prun % % pypy % % python % % python2 % % python3 % % ruby % % script % % sh % % svg % % sx % % system % % time % % timeit % % writefile Automagic is ON, % prefix IS NOT needed for line magics.
% who ?
[0;31mDocstring:[0m
Print all interactive variables, with some minimal formatting.
If any arguments are given, only variables whose type matches one of
these are printed. For example::
%who function str
will only list functions and strings, excluding all other types of
variables. To find the proper type names, simply use type(var) at a
command line to see how python prints type names. For example:
::
In [1]: type('hello')
Out[1]: <type 'str'>
indicates that the type name for strings is 'str'.
``%who`` always excludes executed names loaded through your configuration
file and things which are internal to IPython.
This is deliberate, as typically you may load many modules and the
purpose of %who is to show you only what you've manually defined.
Examples
--------
Define two variables and list them with who::
In [1]: alpha = 123
In [2]: beta = 'test'
In [3]: %who
alpha beta
In [4]: %who int
alpha
In [5]: %who str
beta
[0;31mFile:[0m ~/anaconda3/envs/mikedev/lib/python3.8/site-packages/IPython/core/magics/namespace.py
% magic #To display the IPython help
for magic functions(note, a lot of output!)