import pty;pty.spawn code example Example: python spawn shell python -c 'import pty;pty.spawn("/bin/bash")'