I'm preparing a workshop on Moco and setting up an environment in Google Colab to run some examples. Here's the link:
https://colab.research.google.com/drive ... sp=sharing
Everything works well: I installed OpenSim successfully and was able to run a simple example. However, I'm facing an issue with terminal output in Google Colab. When I run solution = study.solve(), no output is displayed in the notebook, even though the function executes, and I can save the results. This happens because Colab doesn't handle standard terminal output the same way as a local terminal, so it runs the code silently.
I've tried a few methods to capture the output.
1) Redirecting sys.stdout to /dev/stdout. This results in an OSError since Colab doesn't seem to have access to /dev/stdout.
Code: Select all
sys.stdout = open('/dev/stdout', 'w')
Code: Select all
import io
buffer = io.StringIO()
sys.stdout = buffer
solution = study.solve()
sys.stdout = sys.__stdout__
print(buffer.getvalue())
3) I also tried using contextlib.redirect_stdout to redirect the output to a StringIO object, but again, nothing was printed.
I know it is not the most usual execution, but I wondered if anyone else understands more about Jupyter's notebook-like environments. Do you have any suggestions on how to get the full terminal execution details to appear?