Google Colab ngrok convert to python

I have a Google Colab notebook with following commands

!wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip

!unzip ngrok-stable-linux-amd64.zip

LOG_DIR = './log'
get_ipython().system_raw(
    'tensorboard --logdir {} --host 0.0.0.0 --port 6006 &'
    .format(LOG_DIR)
)

These commands run very well without any error in Google Colab . But when I run the same in python get error.

Python demo.py

import sys, json
import requests
from IPython import get_ipython
import requests

LOG_DIR = './log'

get_ipython().system_raw(
    'tensorboard --logdir {} --host 0.0.0.0 --port 8001 &'
    .format(LOG_DIR)
)

ERROR: line 9: AttributeError: 'NoneType' object has no attribute 'system_raw'

How do I resolve this error in python ?