Bonnjour,
j'ai besoin de compiler mon outil developpé en python afin de le faire tourner sur plusieurs plateformes (Solaris, Lunix...) sans possibilité d'installer python.
J'ai trouvé pyinstaller et suivi le tutoriel fourni mais je n'ai pas trouvé d'information sur mon cas de figure.
L'executable généré crash car les modules (que j'ai développé et non ceux de python) ne sont pas importé, donc probablement pas packagés.
Le code suivant est celui du script principal.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 try: TOOLS_ROOT = os.environ['TOOLS_ROOT'] sys.path.append(TOOLS_ROOT) except KeyError: print 'TOOLS_ROOT is undefined. Please set it.' sys.exit(1) import lib.globals from lib.parserLib import Architecture import thread import threading ...
Voici mon arborescence fichier de mon outil
/tool/__init__.py
analyzer.py
lib/__init__.py
globals.py
parserLib.py
Donc quelques questions:
- comment se passer de la déclaration de la variable d'environnement global TOOLS_ROOT qui définit le root de mon script analyzer.py ?
Voici la sortie d'erreur de l'executable si je ne déclare pas cette variable
- comment indiquer à pyinstaller qu'il faut packager les modules importés dans mes fichier python ?vmintegration:~/pyinstaller-1.4/analyzer# ./dist/analyzer
TOOLS_ROOT is undefined. Please set it.
vmintegration:~/pyinstaller-1.4/analyzer#
Voici la sortied d'erreur de l'executable si je décalre TOOLS_ROOT (avec une valeur arbitraire car non utile normalement)
- comment integrer des arguments à la ligne de commande si besoin est ?vmintegration:~/pyinstaller-1.4/analyzer# export TOOLS_ROOT=`pwd`
vmintegration:~/pyinstaller-1.4/analyzer# ./dist/analyzer
Traceback (most recent call last):
File "<string>", line 21, in <module>
File "/root/pyinstaller-1.4/iu.py", line 455, in importHook
raise ImportError, "No module named %s" % fqname
ImportError: No module named lib
Voici la sortie d'erreur de l'executable si le TOOLS_ROOT est défini au véritable chemin de mon script et que l'executable est lancé sur ma machine de dev
Voici le contenu du fichier warnlogs si cela peut aider.vmintegration:~/pyinstaller-1.4/analyzer# export TOOLS_ROOT=/home/stephane/tool
vmintegration:~/pyinstaller-1.4/analyzer# ./dist/analyzer
ERROR : Arg <opt> missing in command line ****
Voici l contenue de mon fichier .specW: no module named AES (delayed, conditional import by archive)
W: no module named sgi (delayed import by pty)
W: no module named lib (top-level import by __main__)
W: no module named report (top-level import by __main__)
W: no module named org (top-level import by copy)
W: no module named _emx_link (conditional import by os)
W: __all__ is built strangely at line 0 - __future__ (/usr/lib/python2.5/__future__.pyc)
W: delayed __import__ hack detected at line 0 - encodings (/usr/lib/python2.5/encodings/__init__.pyc)
W: delayed __import__ hack detected at line 0 - optparse (/usr/lib/python2.5/optparse.pyc)
W: delayed eval hack detected at line 0 - os (/usr/lib/python2.5/os.pyc)
W: __all__ is built strangely at line 0 - tokenize (/usr/lib/python2.5/tokenize.pyc)
W: delayed conditional exec statement detected at line 0 - iu (/root/pyinstaller-1.4/iu.pyc)
W: delayed conditional exec statement detected at line 0 - iu (/root/pyinstaller-1.4/iu.pyc)
W: delayed eval hack detected at line 0 - __main__ (/home/stephane/python/script/analyzer.py)
W: delayed conditional eval hack detected at line 0 - __main__ (/home/stephane/python/script/analyzer.py)
W: delayed eval hack detected at line 0 - __main__ (/home/stephane/python/script/analyzer.py)
W: delayed conditional eval hack detected at line 0 - __main__ (/home/stephane/python/script/analyzer.py)
W: delayed conditional eval hack detected at line 0 - __main__ (/home/stephane/python/script/analyzer.py)
W: delayed eval hack detected at line 0 - __main__ (/home/stephane/python/script/analyzer.py)
W: delayed eval hack detected at line 0 - __main__ (/home/stephane/python/script/analyzer.py)
W: delayed conditional eval hack detected at line 0 - __main__ (/home/stephane/python/script/analyzer.py)
W: delayed eval hack detected at line 0 - __main__ (/home/stephane/python/script/analyzer.py)
W: delayed conditional eval hack detected at line 0 - __main__ (/home/stephane/python/script/analyzer.py)
W: delayed conditional eval hack detected at line 0 - __main__ (/home/stephane/python/script/analyzer.py)
W: delayed eval hack detected at line 0 - gettext (/usr/lib/python2.5/gettext.pyc)
W: delayed conditional eval hack detected at line 0 - warnings (/usr/lib/python2.5/warnings.pyc)
W: delayed conditional __import__ hack detected at line 0 - warnings (/usr/lib/python2.5/warnings.pyc)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 # -*- mode: python -*- a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), os.path.join(HOMEPATH,'support/useUnicode.py'), '/home/stephane/python/script/analyzer.py'], pathex=['/root/pyinstaller-1.4']) pyz = PYZ(a.pure) exe = EXE( pyz, a.scripts, a.binaries, a.zipfiles, a.datas, name=os.path.join('dist', 'analyzer'), debug=False, strip=False, upx=True, console=1 )
merci d'avance pour votre aide.
J'ai lu pas mal de documentation sur pyinstaller mais rien de très clair qui me permettre de résoudre mon soucis.
Cordialement
Partager