iPython error when importing fastai.text

I am using SageMaker ml.p2.xlarge notebook instance. I am trying to run a .py script. I get an error while trying to import from fastai.text.

PS: I was running a shellscript from a python notebook using the %%sh magic

Here is the error message below:

Traceback (most recent call last):
File “test.py”, line 2, in
from fastai.text import *
File “/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/fastai/text/init.py”, line 1, in
from … import basics
File “/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/fastai/basics.py”, line 1, in
from .basic_train import *
File “/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/fastai/basic_train.py”, line 6, in
from .utils.ipython import gpu_mem_restore
File “/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/fastai/utils/ipython.py”, line 27, in
IS_IN_COLAB = is_in_colab()
File “/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/fastai/utils/ipython.py”, line 24, in is_in_colab
if IS_IN_IPYTHON and ipython_is_colab(): return True
File “/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/fastai/utils/ipython.py”, line 22, in ipython_is_colab
return get_ipython().class.module == ‘google.colab._shell’
NameError: name ‘get_ipython’ is not defined

Does this mean the library only works within Jupyter/ iPython. How do I use it in a script?