<div dir="ltr">I think I am starting to understand bit better what is happening. Since qgis (probably) completely embeds the python interpreter, eg. links to libpython, the value of sys.executable does not really map to this situation. Apparently, the interpretation differs depending on the platform.<div><br></div><div>So if I want to start a detached python process, it is not unreasonable to have to look around for the python executable although it would be great if there is some worked out cross-platform approach. </div><div><br></div><div>A pseudo-code strategy (for 2.18) could be:</div><div><br></div><div>on linux, use sys.executable but if sys.version is 3, warn and guess dir(sys.executable)/python2 (check that the file exists). Actually, it should be fine to just always use dir(sys.executable)/python2 .</div><div>on windows (sys.platform.startswith('win')), use dir(sys.executable)/python-qgis.bat</div><div><br></div><div>This appears to work well enough but I suspect there are better approaches ?</div><div><br></div><div>Sort of similarly, killing a detached QProcess seems to require platform specific code as well. os.kill works for linux but windows seems to require its own system executed 'taskkill /pid'.</div><div><br></div><div><div class="gmail_extra">If this all seems to be completely off, any suggestions or ideas are gratefully received,</div><div class="gmail_extra"><br></div><div class="gmail_extra">Andreas</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 5, 2017 at 9:49 AM, Andreas Plesch <span dir="ltr"><<a href="mailto:andreasplesch@gmail.com" target="_blank">andreasplesch@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Using the Python console on 2.18 </div><div><br></div><div>import sys</div><div>sys.executable </div><div><br></div><div>returns</div><div><br></div><div>1) on Windows (2.18.9 32bit):</div><div><br></div><div>'C:\\PROGRA~1\\QGIS2~1.18\\bin<wbr>\\qgis-bin.exe'<br></div><div><br></div><div>which unexpectedly does not appear to be a Python interpreter</div><div><br></div><div>and</div><div><br></div><div>2) on Linux (2.18.3. 64bit)</div><div><br></div><div>'/usr/bin/python'<br></div><div><br></div><div>which does appear to be the Python interpreter in use by the console.<br></div><div><br></div><div>Is there a cross platform way to discover the Python interpreter in current use ? Would 1) considered to be a possible bug somewhere ?</div><div><br></div><div>I want to use it for</div><div><br></div><div>QProcess.startDetached(sys.exe<wbr>cutable, args, root_folder)<br></div><div><br></div><div>Thanks,</div><div><br></div><div>-Andreas<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div><br></div><div><br></div>-- <br><div class="m_-7777548897710309526gmail-m_504506247162704371gmail_signature">Andreas Plesch<br>39 Barbara Rd.<br>Waltham, MA 02453</div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Andreas Plesch<br>39 Barbara Rd.<br>Waltham, MA 02453</div>
</div></div></div>