By default stdout is line buffered when going to a terminal, but uses a larger buffer when being redirected, hence tee and the terminal don't see the output until later.
For ways to get script.py to not buffer the output see the answers to this question Disable output buffering
For example if script.py is:
#!/usr/bin/python3
import time
for i in range(5):
print('This is line', i, flush=True)
time.sleep(1)
Running ./script.py | tee File.txt
will print each line to the terminal as the line is executed - one second apart.
If you remove flush=True
then the entire output is buffered, and nothing is printed until the script finishes 5 seconds later when everything is printed.
2>&1
redirects stderr to stdout, so you may need to apply the same buffering to stderr as well as stdout.