Pythonskript kompilieren funktioniert nicht richtig

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
kingcools
User
Beiträge: 12
Registriert: Montag 17. März 2014, 04:03

Hi,

ich würde gerne ein Skript, welches Selenium verwendet, kompilieren, um es als dedizierte Anwendung verwenden zu können ohne intermediärem Pythoninterpreter.
Habe es sowohl mit Py2Exe als auch mit PyInstaller versucht und beide bekommen es nicht hin eine funktionierende Exe-Datei zu generieren. Es passiert schlicht nichts, wenn ich die Anwendung ausführe, außer dass sich ein leeres Konsolenfenster öffnet, welches sich direkt wieder schließt.

Zunächst hier das Skript:

Code: Alles auswählen

import sys
import libraryoperation # verwendet Selenium
import sendmail
import dateoperations
import os.path

logfile = "log.txt"
def remind(duedays):
    sendmail.sendMail("Stadtbücherei Erinnerung: Bücher fällig in " + str(duedays) + " Tagen.")
    log = open(logfile, "w")
    log.write(dateoperations.getCurrentDate())
    log.close()

def main():  
    duedays = libraryoperation.booksDueIn()
    if duedays is not None:
        if not os.path.exists(logfile):
            if duedays <= 3:
                remind(duedays)
        else:
            if duedays == 3 or duedays == 0:
                log = open(logfile,"r")
                date = log.read(10)
                log.close()
                if date != dateoperations.getCurrentDate():
                    remind(duedays)

    sys.exit()

if __name__ == '__main__':
    main()
[Code=python file=Untitled.py]
[/code]

Habe gestern ein ähnliches Skript kompiliert, welches noch kein Selenium verwendet hatte (sondern PyQt), das wiederum tadellos funktionierte.

Ich verwende Windows7, Python 2.7 32-bit und habe die passenden Versionen von Py2Exe sowie PyInstaller installiert. Nach meinen Googlerecherchen scheint es immer wieder Probleme mit dem Kompilieren von Pythonskripten, die Selenium verwenden, zu geben. Hat jemand Hinweise für mich? Die Tipps im Inet haben alle nichts gebracht. Bin für jede Hilfe dankbar!

Pyinstaller erzeugt dabei z.B. folgende Warnungen:
W: no module named org (delayed import by xml.sax)
W: no module named termios (top-level import by tty)
W: no module named _dummy_threading (top-level import by dummy_threading)
W: no module named grp (top-level import by shutil)
W: no module named cl (delayed, conditional import by aifc)
W: no module named xml.dom.XMLNS_NAMESPACE (top-level import by xml.dom.expatbuilder)
W: no module named posix (conditional import by __main__)
W: no module named pwd (delayed, conditional import by posixpath)
W: no module named org (top-level import by pickle)
W: no module named Carbon (delayed import by plistlib)
W: no module named xml.dom.EMPTY_NAMESPACE (top-level import by xml.dom.minidom)
W: no module named http (top-level import by selenium.webdriver.firefox.webdriver)
W: no module named xml.dom.XMLNS_NAMESPACE (top-level import by xml.dom.minidom)
W: no module named winreg (delayed, conditional import by selenium.webdriver.firefox.firefox_binary)
W: no module named fcntl (conditional import by subprocess)
W: no module named pwd (top-level import by shutil)
W: no module named java (conditional import by xml.sax._exceptions)
W: no module named http (top-level import by selenium.webdriver.safari.webdriver)
W: no module named pwd (top-level import by tarfile)
W: no module named readline (delayed import by pdb)
W: no module named _scproxy (conditional import by urllib)
W: no module named _sysconfigdata (delayed import by distutils.sysconfig)
W: no module named pwd (delayed import by getpass)
W: no module named EasyDialogs (conditional import by getpass)
W: no module named termios (top-level import by getpass)
W: no module named grp (top-level import by tarfile)
W: no module named xml.dom.XML_NAMESPACE (delayed import by xml.dom.pulldom)
W: no module named gestalt (delayed import by platform)
W: no module named org (top-level import by copy)
W: no module named fcntl (top-level import by tempfile)
W: no module named xml.dom.EMPTY_PREFIX (top-level import by xml.dom.minidom)
W: no module named http (top-level import by selenium.selenium)
W: no module named readline (delayed, conditional import by cmd)
W: no module named java (delayed import by platform)
W: no module named cl (delayed import by aifc)
W: no module named xmlparse (top-level import by pyexpat)
W: no module named posix (conditional import by pyi_os_path)
W: no module named MacOS (delayed import by platform)
W: no module named _emx_link (conditional import by os)
W: no module named posix (conditional import by os)
W: no module named xml.dom.DOMImplementation (top-level import by xml.dom.domreg)
W: no module named xmltok (top-level import by pyexpat)
W: no module named rourl2path (conditional import by urllib)
W: no module named vms_lib (delayed, conditional import by platform)
W: no module named pwd (delayed import by webbrowser)
W: no module named xml.dom.EMPTY_NAMESPACE (top-level import by xml.dom.expatbuilder)
W: no module named xml.dom.EMPTY_PREFIX (top-level import by xml.dom.expatbuilder)
W: no module named http (top-level import by selenium.webdriver.remote.remote_connection)
W: no module named SOCKS (top-level import by ftplib)
W: no module named _xmlplus (top-level import by xml)
W: no module named http (top-level import by selenium.webdriver.opera.webdriver)
W: __all__ is built strangely at line 0 - dummy_threading (D:\Python\27\lib\dummy_threading.pyc)
W: delayed exec statement detected at line 0 - bdb (D:\Python\27\lib\bdb.pyc)
W: delayed eval hack detected at line 0 - bdb (D:\Python\27\lib\bdb.pyc)
W: delayed eval hack detected at line 0 - bdb (D:\Python\27\lib\bdb.pyc)
W: delayed __import__ hack detected at line 0 - optparse (D:\Python\27\lib\optparse.pyc)
W: delayed conditional __import__ hack detected at line 0 - doctest (D:\Python\27\lib\doctest.pyc)
W: delayed exec statement detected at line 0 - doctest (D:\Python\27\lib\doctest.pyc)
W: delayed conditional __import__ hack detected at line 0 - doctest (D:\Python\27\lib\doctest.pyc)
W: __all__ is built strangely at line 0 - tokenize (D:\Python\27\lib\tokenize.pyc)
W: __all__ is built strangely at line 0 - tokenize (D:\Python\27\lib\tokenize.pyc)
W: delayed conditional __import__ hack detected at line 0 - pyi_archive (D:\Python\27\lib\site-packages\PyInstaller\loader\pyi_archive.pyc)
W: delayed __import__ hack detected at line 0 - pickle (D:\Python\27\lib\pickle.pyc)
W: delayed __import__ hack detected at line 0 - pickle (D:\Python\27\lib\pickle.pyc)
W: delayed __import__ hack detected at line 0 - encodings (D:\Python\27\lib\encodings\__init__.pyc)
W: delayed __import__ hack detected at line 0 - pydoc (D:\Python\27\lib\pydoc.pyc)
W: delayed __import__ hack detected at line 0 - pydoc (D:\Python\27\lib\pydoc.pyc)
W: __all__ is built strangely at line 0 - dis (D:\Python\27\lib\dis.pyc)
W: __all__ is built strangely at line 0 - hashlib (D:\Python\27\lib\hashlib.pyc)
W: delayed conditional eval hack detected at line 0 - warnings (D:\Python\27\lib\warnings.pyc)
W: delayed conditional __import__ hack detected at line 0 - warnings (D:\Python\27\lib\warnings.pyc)
W: delayed conditional exec statement detected at line 0 - pyi_importers (D:\Python\27\lib\site-packages\PyInstaller\loader\pyi_importers.pyc)
W: delayed __import__ hack detected at line 0 - email (D:\Python\27\lib\email\__init__.pyc)
W: delayed conditional __import__ hack detected at line 0 - xml.dom.domreg (D:\Python\27\lib\xml\dom\domreg.pyc)
W: delayed exec statement detected at line 0 - pdb (D:\Python\27\lib\pdb.pyc)
W: delayed conditional eval hack detected at line 0 - pdb (D:\Python\27\lib\pdb.pyc)
W: delayed eval hack detected at line 0 - pdb (D:\Python\27\lib\pdb.pyc)
W: delayed conditional eval hack detected at line 0 - pdb (D:\Python\27\lib\pdb.pyc)
W: delayed eval hack detected at line 0 - pdb (D:\Python\27\lib\pdb.pyc)
W: delayed __import__ hack detected at line 0 - pkgutil (D:\Python\27\lib\pkgutil.pyc)
W: delayed conditional __import__ hack detected at line 0 - pkgutil (D:\Python\27\lib\pkgutil.pyc)
W: __all__ is built strangely at line 0 - collections (D:\Python\27\lib\collections.pyc)
W: delayed exec statement detected at line 0 - collections (D:\Python\27\lib\collections.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.main (D:\Python\27\lib\unittest\main.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.loader (D:\Python\27\lib\unittest\loader.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.loader (D:\Python\27\lib\unittest\loader.pyc)
W: delayed __import__ hack detected at line 0 - unittest.loader (D:\Python\27\lib\unittest\loader.pyc)
W: __all__ is built strangely at line 0 - __future__ (D:\Python\27\lib\__future__.pyc)
W: delayed __import__ hack detected at line 0 - xml.sax (D:\Python\27\lib\xml\sax\__init__.pyc)
W: delayed eval hack detected at line 0 - gettext (D:\Python\27\lib\gettext.pyc)
Benutzeravatar
Sr4l
User
Beiträge: 1091
Registriert: Donnerstag 28. Dezember 2006, 20:02
Wohnort: Kassel
Kontaktdaten:

Hast du mal das py2exe oder PyInstaller Ergebnis, also die `Projekt.exe` oder wie auch immer sie heißt, von der Konsole aus gestartet um zu sehen ob da wirklich keine Fehlermeldung kommt?!?
Antworten