Finding out running anaconda environment (not active on new processes or default) from within python
<p>What would be the best way to find the current anaconda environment from within python. </p>

<p>The problem is that it is not the default environment: for example calling </p>

<pre><code>import subprocess
subprocess.call(['conda','info'])
</code></pre>

<p>gives me the wrong result (because it creates a new process, which has the default environment)</p>

<p>I run this using anaconda2 on win7 and running the code from pycharm, but in the best case scenario the solution should work "everywhere" or at least for anaconda</p>

<p>The location of the python.exe that was used to run my program would give the hint me that information, so using e.g.</p>

<pre><code>&gt;&gt;&gt; import sys
&gt;&gt;&gt; print sys.executable
D:\Anaconda2\envs\py2\python.exe
</code></pre>

<p>is one option. </p>

<pre><code>import sys

print sys.version
</code></pre>

<p>Returns: (Something like)</p>

<pre><code>2.7.11 |Anaconda 4.0.0 (64-bit)| (default, Feb 16 2016, 09:58:36) [MSC v.1500 64 bit (AMD64)]
</code></pre>

python anaconda