'Run python script in Jupyter Notebook and get access to variable in Jupyter

I want to run a python script in jupyter notebook and get access to variables in jupyter.

I tried:

!python test.py

I correctly get the output of the script, but after it finishes, i cant get access to variables in test.py.

Then i tried:

%load test.py

It loads the script into jupyter, but it fails due to dependency problems (and it´s very uncomfortable because the file is very large)

So is it possible to run a python script like !python and keep the variables in jupyter for further processing?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source