How can I find out what Python distribution I am using from within Python?
<p>I'm using an application (QGIS) that can execute Python and can be extended with plugins written in Python. Depending on the platform, the installer of this application brings along its own Python distribution which it installs alongside the application to be used by the application. On other platforms, the installation doesn't bring Python along and the system Python interpreter is used.</p>

<p>Can I find out from within Python (in the application's interactive Python console or from within a plugin) what Python is being used?</p>

<p><code>version_info</code> from <code>sys</code> module gives you that answer:</p>

<pre><code>import sys

print sys.version_info
sys.version_info(major=2, minor=7, micro=12, releaselevel='final', serial=0)
</code></pre>

<p>You can get every value of it by using ie.: </p>

<pre><code>print sys.version_info.major
</code></pre>

python