pymod_os_specific.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:pymod 作者: pymodproject 项目源码 文件源码
def find_systemwide_lib(lib_name):
    """
    Check if a systemwide Python library can be imported in PyMOL.
    """
    lib_path = ""
    if sys.platform in ("linux2", "darwin"):
        try:
            # lib_file = subprocess.check_output(["/usr/bin/python2", "-Ec", "import %s; print %s.__file__" % (lib_name, lib_name)]).rstrip()
            r = subprocess.Popen("/usr/bin/python2 -Ec 'import %s; print %s.__file__'" % (lib_name, lib_name),
                                 stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True
                                 ).communicate()
            lib_file = r[0].rstrip()
            if lib_file:
                lib_path = os.path.split(os.path.dirname(lib_file))[0]
        except:
            pass
    return lib_path
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号