Find full path of the Python interpreter?
如何从当前执行的python脚本中找到当前运行的python解释器的完整路径?
包括当前运行的Python译员的全部路径。
1 2 3 | import sys print(sys.executable) |
这是什么
Just noting a different way of questionable usefulness,using EDOCX1&1>
1 2 | import os python_executable_path = os.environ['_'] |
E.G.
1 2 | $ python -c"import os; print(os.environ['_'])" /usr/bin/python |
目前,在Linux使用的Python是:(1)
与Cygwin相似的视窗也会产生同样的结果。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | kuvivek@HOSTNAME ~ $ which python /usr/bin/python kuvivek@HOSTNAME ~ $ whereis python python: /usr/bin/python /usr/bin/python3.4 /usr/lib/python2.7 /usr/lib/python3.4 /usr/include/python2.7 /usr/include/python3.4m /usr/share/man/man1/python.1.gz kuvivek@HOSTNAME ~ $ which python3 /usr/bin/python3 kuvivek@HOSTNAME ~ $ command -v python /usr/bin/python kuvivek@HOSTNAME ~ $ type python python is hashed (/usr/bin/python) |
如果你已经在Python壳。尝试这些。注:这是一种交替的方式。不是最好的Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | >>> >>> import os >>> os.popen('which python').read() '/usr/bin/python ' >>> >>> os.popen('type python').read() 'python is /usr/bin/python ' >>> >>> os.popen('command -v python').read() '/usr/bin/python ' >>> >>> |
Try the whereis command:
ZZU1