Skip to content

Introduce an Interactive shell in your python script with Ipython

Introduce an Interactive shell in your python script with Ipython

# shorts
Introduce an Interactive shell in your python script with Ipython

Install
pip install ipython

from IPython.terminal.embed import InteractiveShellEmbed
from IPython import embed

ipshell = InteractiveShellEmbed()

embed()
ipshell.dummy_mode = True
ipshell.system_raw(“mkdir test”)
# execute command and print result
result = ipshell.getoutput(“ls -l”)
print(result)

Leave a Reply

Your email address will not be published. Required fields are marked *