Decompiling PYC files for python 3.9.2

Question:

Currently, I have a PYC file for the 3.9.2 version of python (P.S: This applies to all versions 3.9 and above).
I’m trying to decompile the PYC file but it is showing an error as uncompyle6 (or rather, the newer version, decompyle3) is not compatible with Python versions 3.9 and above.

I was wondering if there are any alternative methods that can be used rather than decompyle3 to get the source of PYC files, or maybe a hacky fix.

P.S. I did already try to pip install decompyle3 but it says

ERROR: No matching distribution found for decompyle3
Asked By: Gowixx

||

Answers:

You need to pip install decompyle3 from the github link because its not on PyPI:

pip install git+https://github.com/rocky/python-decompile3
Answered By: SuperStormer

Sadly enough, it’s currently impossible.
Decompile 3 has the latest pyc to py methods (decompilation),
but it hasn’t updated for python 3.9 yet as that update takes a very long time to create.
And it will most likely never happen for 3.9 (the developer of decompyle3 said that he is focusing more on his main job and that he doesn’t have time to create this update as the 3.9 python update really changed the workflow, so it will be very hard and time-consuming).

So for now, the only solution is to wait, but if you want to speed things up, you can always sponsor the creator of decompile 3 (https://github.com/sponsors/rocky) (as he said that if you would get enough money to work more on this project, he will)

Edit:
I have recently found out that there is an alternative
I haven’t used it myself, but its meant to decompile the compiled
python file (.pyc) back to humanly readable code (.py). For any python version!
You can check it out here: https://github.com/zrax/pycdc

Answered By: Frostbite

Even if decompilation is not correct a had some success on decompiling Python 3.9 with Decompyle++

pip install pydc

Example:

C:Python310Libsite-packagespydumpckpyc_checkerlib_pycdcpycdc.exe olds.pyc

This will fix the long path to run issue:
set path=%path%;C:Python310Libsite-packagespydumpckpyc_checkerlib_pycdc

You may append >olds.py to the line above to write the output in a file.

Note: Adding 1>&2 to also have strerr output in the file is kinda useless.
It doesn’t merges stdout and strerr lines in the order they are outputed.
Instead it combines all strerr lines and adds them at the begin or end of stdout.

I haven’t found a solution to this.
Hmm maybe >& could help out but I couldn’t tested that yet.

Well that will decompile all files in a path:

for %i in (*.pyc) do C:Python310Libsite-packagespydumpckpyc_checkerlib_pycdcpycdc.exe %i >%~ni.py
Answered By: Nadu