I'm getting an error with Uncompyle6 and Decompyle3 after getting the bytecode from pyinstxtractor

3.7k Views Asked by At

I got this error when I tried Uncompyle6 uncompyle6 main.pyc :


Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Scripts\uncompyle6.exe\__main__.py", line 4, in <module>

...more lines

  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\xdis\std.py", line 73, in __init__
    self.opc = opc = get_opcode_module(python_version, variant)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\xdis\op_imports.py", line 174, in get_opcode_module
    return op_imports[canonic_python_version[vers_str]]
                      ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: '3.11.2'

So, I tried Decompyle3. Yet, I get the same error. I tried Decompyle3 because "it accepts bytecodes from Python version 3.7 on." I'm using Python 3.11.

So, if that's not gonna work, then what should I do???

PS: Is there any other software that could do this? I think something is wrong with my Python version.

3

There are 3 best solutions below

0
On

Use pyenv for older python versions like 3.7,3.8.... with, pyenv install 3.8.0. Now set this either globally or locally with, pyenv global 3.8.0. Now to get it implemented for the terminal if restart doesn't work, source ~/.bashrc. Check with, python --version. Finally to install uncompyle6, pip install uncompyle6. Now to make it work, uncompyle6 _pycFileHere_. And BOOMMMMMMM!!!

0
On

I had this same issue and fixed it by updating magics.py in my xdis instalation to include you're python version (or just copy the newer version from the xdis github - the PyPi version might be out of date).

KeyError means that the key being looked up the "canonic_python_version" is not valid (aka dosn't have an entry in the dictionary), and this dictionary is imported from magics.py)

if you're python version is too new, it may also not yet be suported, in which case you might need to run the module with an older version of python (still may need to update magics.py regardless)

1
On

I might be wrong here, but I believe KeyError: 3.11.2 means that version of python isn't supported (at least yet) by decompyle6. I know it works up to python 3.8.x

You can see more info here: https://github.com/rocky/python-decompile3/issues/45