ptyprocess

Run a subprocess in a pseudo terminal

Here are some articles that you may find helpful