You're mixing Python 2.7 and 3.x code.
You could convert the scripts with 2to3 or other tools.
Another approach could be, to have two different installed Python-Versions.
Then you can't use sys.executable, if you run Python3.
In this case the sys.executable is Python3.
On the most Linux systems /usr/bin/python is a symlink to python2.7 and /usr/bin/python3 is a symlink to a 3.x version of the Python interpreter. On Mac it's similar I guess. On Windows you should use the programm py, which is installed together with newer python versions. I think it's delivered since Python 3.5.
This helper command finds the right interpreter for you. You just specify which version you want to have.
The same with Python 3. If you want to have a Python 3 interpreter, just use 3 as version. Python 3.7.x is version 37. The dot is not used.
Another error is in the file "/sdc1/Apps/Modeling/FileEditing/untitled1m2.py", line 12
Additionally I added encoding to subprocess. Then you get native strings instead of bytes.
With no specification of encoding, you get raw-bytes. This is interesting, if a program sends binary data to stdout.
You may have to change the encoding to another, if you use Python 2.
You could convert the scripts with 2to3 or other tools.
Another approach could be, to have two different installed Python-Versions.
Then you can't use sys.executable, if you run Python3.
In this case the sys.executable is Python3.
On the most Linux systems /usr/bin/python is a symlink to python2.7 and /usr/bin/python3 is a symlink to a 3.x version of the Python interpreter. On Mac it's similar I guess. On Windows you should use the programm py, which is installed together with newer python versions. I think it's delivered since Python 3.5.
This helper command finds the right interpreter for you. You just specify which version you want to have.
from subprocess import Popen, PIPE def run_script(script_path, python_version=3, encoding='utf8'): return Popen(['py', f'-{python_version}', script_path], stdout=PIPE, stderr=PIPE, encoding=encoding)To use Python 27, version have to be 27. If you want to have any available Python 2 version, you specify just 2 as version number.
The same with Python 3. If you want to have a Python 3 interpreter, just use 3 as version. Python 3.7.x is version 37. The dot is not used.
Another error is in the file "/sdc1/Apps/Modeling/FileEditing/untitled1m2.py", line 12
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stdout=subprocess.PIPE)2 times stdout. The second one should be stderr. Just a copy paste error.
Additionally I added encoding to subprocess. Then you get native strings instead of bytes.
With no specification of encoding, you get raw-bytes. This is interesting, if a program sends binary data to stdout.
You may have to change the encoding to another, if you use Python 2.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!