Compilation des fichiers sources pyhton en executables sous windows
3edbill69
Messages postés12Date d'inscriptionlundi 16 août 2004StatutMembreDernière intervention26 septembre 2006
-
11 janv. 2006 à 01:44
xmaw
Messages postés2Date d'inscriptionlundi 3 novembre 2008StatutMembreDernière intervention28 février 2010
-
28 févr. 2010 à 09:42
J'ai fait une recherche et j'ai trouvé qu'il y avait des compilateurs
pour les fichiers .py qui donnent des executables indépendants de
python qui peuvent théoriquement marcher sur windows...malheureusement
je viens de commencer python et je ne comprends pas du tout où je me
plante mais je sais que ça plante:
Assuming you have written a python script <tt literal="">myscript.py</tt> which you
want to convert into an executable windows program, able to run on
systems without a python installation. If you don't already have
written a distutils setup-script, write one, and insert the
statement <tt literal="">import py2exe</tt> before the call to the setup function:
# setup.py
from distutils.core import setup
import py2exe
setup(console=["myscript.py"])
Running
python setup.py py2exe --help
will display all available command-line flags to the py2exe
command.
Now you can call the setup script like in this way:
python setup.py py2exe
and a subdirectory <tt literal ="">dist</tt> will be created, containing the files
<tt literal= "">myscript.exe</tt>, <tt literal="">python23.dll</tt>, and <tt literal="">library.zip</tt>. If your script
uses compiled C extension modules, they will be copied here as well,
also all dlls needed at runtime (except the system dlls).
These files include everything that is needed for your program, and
you should distribute the whole directory contents.
The above setup script creates a console program, if you want a GUI
program without the console window, simply replace
<tt literal="">console=["myscript.py"]</tt> with <tt literal="">windows=["myscript.py"]</tt>.
py2exe can create more than one exe file in one run, this is
useful if you have a couple of related scripts. Pass a list of all
scripts in the <tt literal ="">console</tt> and/or <tt literal="">windows</tt> keyword argument.
xmaw
Messages postés2Date d'inscriptionlundi 3 novembre 2008StatutMembreDernière intervention28 février 2010 28 févr. 2010 à 09:42
fait comme sa
from distutils.core import setup
import sys
import py2exe
sys.argv.append("py2exe")
setup(console=["tonprogramme.py"])
ou
setup(windows=["tonprogramme.py"])