Can I find the path to the python executable from inside python?
本问题已经有最佳答案,请猛点这里访问。
Possible Duplicate:
How to get current python interpreter path from inside a Python script?
号
标题上写的差不多。我想知道在python内部使用的是哪个python可执行文件。有点像
1 2 3 4 5 6 | Python 2.7.2 (default, Nov 1 2011, 03:31:17) [GCC 4.4.5] on linux2 Type"help","copyright","credits" or"license" for more information. >>> print <insert the code I'm after here> /usr/local/bin/python2.7 >>> |
1 2 3 4 5 6 | Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) [GCC 4.4.5] on linux2 Type"help","copyright","credits" or"license" for more information. >>> print <insert the code I'm after here> /usr/bin/python2.6 >>> |
号
你拿到照片了
谢谢
您可以这样做:
1 2 3 | >>> import sys >>> print sys.executable /usr/bin/python |
号
如前所述:如何以编程方式获取python.exe位置?
为什么不直接使用bash
不管怎样,你要找的是:
1 2 | import sys sys.executable |