Natron RunScript doesn't like python.

I’m running on Ubuntu 20.04. Trying to use the RunScript node in Natron.
This runs fine:

touch /tmp/shtouch

But when I try this, I get nothing:

#!/usr/bin/env python3
from pathlib import Path

I made a python script of the above, it runs.

this runs, I get the version into in /tmp/pythoninfo

#!/usr/bin/env bash
python3 --version >/tmp/pythoninfo

this does nothing in RunScript, I added some prints before and after the touch above. It runs successfully on command line.

#!/usr/bin/env bash
python3 <path to>/ >/tmp/pyout 2>&1

It just doesn’t make sense to me. What am I missing?

This will be interpreted as an bash script, like running sh, and will of course not work.

Make sure everything in RunScript are shell commands, wrap your Python commands or something.

Actually no, in the docs is says use #!/usr/bin/env python to run python, but examples are just #!/bin/bash.
I also looked at the test code, that is only testing #!/bin/bash
Then I took a peek at the RunScript code itself. It creates a temp file with the contents in the window, makes that file executable and runs it with popen. You can actually run any script code in there, bash, python, perl, csh and so one
A colleague spotted the real problem, it is the environmental variables that are set for python, namely PYTHONNOUSERSITE and PYTHONPATH. Unless you are using Natron’s python, a python script will fail when it tried to load Natron’s python libraries.
The best fix is the following:
#!/usr/bin/env -S -uPYTHONNOUSERSITE -uPYTHONPATH python3
And you are in business.
This unset those variables and the -S does some other magic.

1 Like

Yes, I was wrong. Thanks for the clarification and proposed workaround.