1

I'm trying to load a python extension to WinDBG, using PyKd.

.load pykd succeeds.

When I'm running !py, I get this:

failed to find python interpreter

Things I've tried:

  • Different versions of python

  • Using PyKd's dll and pyd files

  • .reload /f

  • Different symbol paths

  • Debugging WinDBG and PyKd, also going through the source, no success

Yes, my environment is set correctly with the Python path.

Couldn't find any mention of that problem in the web. It had always ran smoothly on different systems and configurations I had, but on my new system I get this weird message.

Details:

Windows 10 Home, version 1607, x64

WinDBG x86, build 10.0.15063.0

Python 2.7.13, but I tried many other versions as well.

Symbols path: cache*c:\symbols;srv*https://msdl.microsoft.com/download/symbols

Dell XPS 15

Steve
  • 19
  • 2

5 Answers5

1

guy I installed the latest pykd too, and occur the same problem.

Then I found that I hadn't installed python 2.7 at this virtualbox.

Installing python 2.7 will work. You have installed it.I suggest you check whether python installation path is in "path" environment variable

p5ygh0
  • 11
  • 1
1

if you don't have this register path:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\xx\PythonPath, then you should install python-2.7(x64) with Path enabled.enter image description here

VictorV
  • 637
  • 7
  • 16
1

I had this issue when having multiple python installations on the same machine. Managed to solve it by manually creating required registry key, as I did not want to reinstall any python versions, nor change the global path/pythonpath variables.

Note that you will need x64 python for windbgx64 and x86 python for windbgx86

Let's say you want to use python 3.7x86 installed at c:\python37_x86, and python 3.6x64 installed at c:\python36_x64

  1. Create keys leading to HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Python\PythonCore\3.7-32\InstallPath there, and set the (Default) to c:\python37_x86\ (the trailing backslash is important!)

  2. Similarly, create keys leading to HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.6\InstallPath there, and set the (Default) to c:\python36_x64\

  3. Unfortunately the PYTHONPATH environment variable is still being used, and must match the referenced python version(otherwise you will encounter Fatal Python error: unable to load the file system codec . NOTE: this may only be important if one of the versions is 2.x and the other 3.x. Try making it work without this step

To circumvent the last issue I created .bat files to modify the environment and launch windbg with the correct environment.

For example for launching 32 bit windbg:

set PYTHONPATH=C:\python37_x86\Lib;[...Rest of the PYTHONPATH for this python version...]
start windbgx -debugArch x86 -c ".load c:\dev\tools\pykd\x86\pykd.dll"
Arthur.V
  • 676
  • 1
  • 8
  • 22
  • Thank you for this fix. Now I hate WinDbg even more. This program is so baaaaad, I'm throwing hands in the air. – KulaGGin Dec 14 '21 at 10:17
0

WinDBG x86, build 10.0.15063.0 Python 2.7.13, but I tried many other versions as well.

You need python 2.7.13 x86

After installation you can check it visibility for pykd with command pykd.info - it should show path to python. For python 2.7 it is commonly C:\windows\system32\python27.dll

pykd_team
  • 131
  • 3
0

Also had the same issue, in the end it depends on which windbg version you are using, and what python versions you have installed;

  • If it is windbg x86, you need python 32 bits installed.
  • If it is windbg x64, you need python 64 bits installed.

I did not have to add any specific version to the PATH, I have 3 versions of python in my system; python2.7x86, python2.7x64 and python3x64 and if I run !pykd.info in windbgx86 it recognizes both x86 pythons and if I run it in sindbgx64 it recognizes the x64 python.

If your !pykd.info does not list any python, you probably have them mixed up (you only have pythonx86 while running windbgx64, or you only have pythonx64 while running windbgx86).