I'm using cx_Freeze to freeze my python program. On running cx_Freeze, a bunch of PYD files are created, a whole bunch of PYC files are put into a archive named library.zip and a few DLL files are there too.
Could someone tell me the difference between the PYC and the PYD files?
What's the reason for the PYD files not in the library.zip?
Is it possible to put the PYD files into the archive as well?
Thanks.
Disclaimer: I haven't used cx_Freeze in awhile......
.PYD files are DLL machine-code files that contain specific python-required functions.
.PYC files are .py files that have been compiled into bytecode.
so PYDs are machine code and PYCs are bytecode
Now as for why the PYDs aren't in the .zip....I'd imagine it's because those .PYDs are needed by the python interpreter to run the program. What cx_Freeze does is basically this:
compile all .py files and throw the .pyc files in a zip
put all needed .pyd files in the zip
create a stub .py file and put it in the output directory
copy the python.exe and rename to myprogram.exe
copy all .pyd files needed to open the .zip and run the contents
So you're not actually compiling your python file, you're instead renaming the interpeter and freezing all the source files.
I hope this helps.
Related
I have decompiled a .exe compiled.
I got a .pyz file and some other files:
Extracted them and got this:
How am I able to get the .py file from all those .pyc files?
You can decompile .pyc files yes - see these similar questions:
Is it possible to decompile a compiled .pyc file into a .py file?
https://reverseengineering.stackexchange.com/questions/1701/decompiling-pyc-files
The short of it is that you can use a tool to generate .py files from .pyc:
https://github.com/rocky/python-uncompyle6/
Is it possible to include both .so (cython compiled) and .py files in a folder with same name. Which one will python use if I use import ?
My question is how decompile .pyc file to python code. In first place I had exe file, i extracted .pyz file from it. From .pyz file i extracted .pyc files with this http://www.pyinstaller.org/browser/project/PyInstaller/cliutils/archive_viewer.py
However when i try to decompile .pyc files I receive erro that magic number is invalid. I looked it up, and its 63 (hex) and 99 in decimal. I guess Pyinstaller makes some changes to pyc files, my question is how to decompile this .pyc file.
I have created some tools which will help in dealing with pyinstaller.
There are many ways you can go.
If you just want to extract the exe to get all the embedded files, including the ones inside the pyz use this script.
Afterwards use Easy Python Decompiler to decompile the pyc files.
If you want to dig deeper and recompile the exe then use Pyinstaller exe rebuilder tool.
I am running pygame (for Python) on Windows. I have some .pyo files and some .pyd files. I have another script for somewhere else that is trying to import one of the .pyd files as a module but I keep getting the error that no such module exists.
Do .pyo files have issues importing .pyd files as modules? What can I do to solve this issue?
It's typically because of one or more of the following:
The .pyd is not in your current path (you said it was in the same folder so that should not be the problem)
A DLL the .pyd depends on is not in your current path. Locate the missing DLL's using depends.exe or its modern rewrite and either copy these dll's to the same folder or add the containing directories to your system path
You're using a debug version of python. Then the module must be renamed from xyz.pyd to xyz_d.pyd.
I'm using cx_freeze to freeze a Python script for distribution to other windows systems. I did everything as instructed and cx_freeze generated a build\exe.win32-2.6 folder in the folder containing my sources. This directory now contains a a bunch of PYD files, a library.zip file, the python DLL file and the main executable. Which of these files would I need to distribute? Any help, guys?
Thanks in advance.
You need all of them.