Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

location of python27.dll from python itself

Tags:

python

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)

like image 785
Captain Jack sparrow Avatar asked Jul 31 '14 08:07

Captain Jack sparrow


People also ask

What is Python27?

Python 2.7 is scheduled to be the last major version in the 2. x series before it moves into an extended maintenance period. This release contains many of the features that were first released in Python 3.1. Improvements in this release include: An ordered dictionary type.

Does Python have DLL?

New in Python version 2.5 is the ctypes, a foreign function library. It provides C-compatible data types and allows calling functions in DLLs or shared libraries. Using the ctypes module in Python allows ArcObjects code written in C++ to be used in a geoprocessing script tool.


1 Answers

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/

like image 80
Kenny D Avatar answered Sep 25 '22 23:09

Kenny D