I want to make an executable file (.exe) of my Python application.
I want to know how to do it but have this in mind: I use a C++ DLL!
Do I have to put the DLL along side with the .exe or is there some other way?
I want to make an executable file (.exe) of my Python application.
I want to know how to do it but have this in mind: I use a C++ DLL!
Do I have to put the DLL along side with the .exe or is there some other way?
py2exe can generate single file executables. see this link for examples.
The setup.py I use uses the following combination of options:
'compressed': 1,
'optimize':2,
'bundle_files': 1
I usually add external dlls (p.e. msvcr71.dll) in the same folder where the executable is.
To facilitate distribution and to automate installation after generating your exe you can use Inno Setup to create an installer that puts your exe and your dlls, and other documents (readme, etc) into the application directory
Follow These Steps: You can find this documentation in this site.
Assuming you have PIP installed in this directory c:\PythonXX\Scripts if not go to this site and see instructions on how to "Install Python Indexing Project (PIP)". Go to your command prompt and type the following command.
Go to this SITE and look for the executable named pywin32-218.win32-py2.7.exe 2.7 which is for 32 bit systems for python27 look for the one that corresponds to you. Run the executable file and it should install PyWin32 successfully which works hand in hand with pyinstaller!
Now that you have PyInstaller and PyWin32 you can start to create the single executable file. The single executable file will be created inside another folder called “dist” this folder is also created dynamically when you run the pyinstaller command. To make things clear your pyinstaller files where copied by you to another folder probably called "pyinstaller_files" folder so now type the following command in your command prompt.
The above command will create a folder called “dist” inside the pyinstaller_files folder this folder will contain your single executable file “yourscript.exe”. You can now move the single executable file somewhere of your choice and delete the “dist” & “build” folder with the “yourscript.spec” file as they are no longer needed to run your single executable file.
Use py2exe. You can put the DLL in the same folder as the final EXE and it should be loaded fine.
I've built exe files from Python 2.7 code using each of these tools:
These all will produce a standalone exe. Your installer will have to include the requisite CRT dlls. Your end result will be indistinguishable from any other exe to the typical user.
The first two compile to C first, then compile that to a final exe using whatever compiler you have installed. Py2Exe bundles Python and all your .pyo files into a zip which it embeds in the exe. When launched it unzips to the temp directory and runs the python from there. You'll need to add your dll to the .spec file so it is included in the zip resource. Alternatively, install your dll alongside the exe and load it using an absolute path in python.
Have a look at pyinstaller. It should find (and correspondingly ship) these dependencies for you.
cx_Freeze is a good one as well.
cx_Freeze is a set of scripts and modules for freezing Python scripts into executables
PyInstaller is the best choice, because it works well on both Windows and Linux.
If you are using arch linux, use this link: PyInstaller or try yaourt pyinstaller
.