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
评论列表
文章目录