Is there a way to get the path of python27.dll from the python interpreter itself in windows.
I am looking for something like sys.executable that can get me the path to python27.dll ( just the directory ould do as well)
You can use pywin32 to get a list of DLLs used by the python executable, then search those for python27.dll:
import win32process
for process in win32process.EnumProcessModules(-1):
name = win32process.GetModuleFileNameEx(-1, process)
if "python27.dll" in name:
print name
In the above example, -1 is the pseudo-process handle for the current process. You can also get the handle via:
curHandle = win32process.GetCurrentProcess()
pywin32 is available for download here:
http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/
If you assume that, python27.dll get installed at system path, you can extract the absolute path by this way:
import subprocess
print subprocess.check_call("where python27.dll")
output:
C:\Windows\System32\python27.dll
0
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.