简体   繁体   English

当前Python实例的路径?

[英]Path of current Python instance?

I need to access the Scripts and tcl sub-directories of the currently executing Python instance's installation directory on Windows. 我需要访问Windows上当前正在执行的Python实例的安装目录的Scriptstcl子目录。

What is the best way to locate these directories? 找到这些目录的最佳方法是什么?

Have a look at sys.prefix and sys.exec_prefix 看看sys.prefixsys.exec_prefix

>>> import sys
>>> sys.prefix
'/System/Library/Frameworks/Python.framework/Versions/2.6'
>>> sys.exec_prefix
'/System/Library/Frameworks/Python.framework/Versions/2.6'

嗯,从sys.path找到Lib目录,然后从那里推断出来?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM