如何知道在ipython下运行哪个python?

时间:2013-01-24 11:32:50

标签: python ipython

我的计算机上安装了几个版本的python:

$ which ipython
/usr/local/share/python/ipython
$ ipython
Python 2.7.3 (default, Nov 28 2012, 13:43:07) 

$ which python
/usr/bin/python
$ python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) 

我想找到在我的ipython下运行的python bin。 谢谢你的帮助

2 个答案:

答案 0 :(得分:8)

In [1]: import sys

In [2]: sys.version
Out[2]: '2.7.2 |EPD_free 7.2-2 (32-bit)| (default, Sep 14 2011, 11:02:05) [MSC v.1500 32 bit (Intel)]'

In [3]: sys.executable
Out[3]: 'C:\\Python27\\python2.7.exe'

答案 1 :(得分:3)

试试这个:

head -n 1 $(which ipython)