I'm trying to convert my .PY script into a .EXE file, in the pro开发者_C百科cess I have tried PY2EXE with the following command line..
python C:\Users\Noob\Desktop\setup.py py2exe -p ftplib
-> -p ftplib is for my module import.
When I use this code, I'm left with an .EXE and a bunch of files, if I take the .EXE out then it will come up with an error. It is required to have "_socket.pyd" and "python26.dll" or it will crash (the program). How do I compile this (not having to use PY2EXE or having to use it) without these extra files?
Thanks a lot!
You should not be taking the exe out of your folder and executing. Just execute it from the dist
directory where got created, it has the python26.dll which the executable needs. If you want to ship it, zip the dist directory and ship it. Otherwise you have to create an installer using specific installer software like NSIS.
I hope you took a look at the Python2.6 specific section, which has details on how to write data_files to include msvcr90.dll
Also, I am finding this -p ftplib
cmd option pretty new. Usually all things to do are within setup.py. Can you point out where this kind of option specification is mentioned.
It is possible to make single file executables with py2exe, the setup.py
file would look something like this:
from distutils.core import setup
import py2exe
setup(
console=['yourscript.py'], # list of scripts to convert into console exes
zipfile=None, # library files in exe instead of zipfile (defaults to "library.zip")
options = {
'py2exe': {
'bundle_files': 1, # bundle dlls and python interpreter in the exe
}
}
)
See py2exe's list of options for more info. Also have a look at the "What are all those files?" question from the FAQ.
You might also want to have a look at PyInstaller (which seems to be doing a better job of creating single file exe's with Microsoft MSVCR*.DLL files included if you need those) Be sure to use the 1.5 series for python 2.6 on Windows.
精彩评论