2017-10-09 3 views
0

Ich versuche 2 Optionen mit pyinstaller eins mit Konsole und eins ohne.pyinstaller eine Datei --no-console funktioniert nicht "Fatal Error"

Ich verwende Windows 10, Python 3.5.4, Windows Chrome Driver 2.33 und Selnium 3.6.0 und Pyinstaller 3.3.

Die eine ohne Konsole schlägt fehl:

Hier ist der Code für Test.py

#!python3 
from selenium import webdriver 

# Chrome Proxy options and disable the Yellow Bar about Chrome being controlled by Automated Software. 
chrome_options = webdriver.ChromeOptions() 
chrome_options.add_argument("--disable-infobars") 
chrome_options.add_argument("--disable-logging") 
chrome_options.add_argument("--disable-notifications") 
chrome_options.add_argument("--disable-default-apps") 
chrome_options.add_argument("--disable-extensions") 


# load google.com with the proxy settings and a logging path to a file 
driver = webdriver.Chrome(r"D:\Selenium\chromedriver_win32\chromedriver.exe", chrome_options=chrome_options) 

# maximise window 
driver.maximize_window() 

driver.get("https://www.google.com/mail") 

Hier sind die pyinstaller Befehle mit der exakt gleichen Code:

- Mit Konsolenfenster alias Werke:

pyinstaller -F -i favicon.ico Test.py 

- Ohne das Konsolenfenster nicht

pyinstaller -F --noconsole -i favicon.ico Test.py 

ich diesen Fehler:

*"Failed to execute script error"* 

Ich bin nicht sicher, warum.

Dank


Vielen Dank für Ihre Antwort sah ich in:

C:\Users\testuser\AppData\Local\Programs\Python\Python35\Lib\site-packages\selenium\webdriver\chrome\service.py 

Es gibt nichts für subprocess hier war.

Ich habe auch:

C:\Users\testuer\AppData\Local\Programs\Python\Python35\Lib\site-packages\selenium\webdriver\common\service.py 

On line 70 I in dem Eintrag hinzugefügt für stdin = self.log_file wie es

try: 
      cmd = [self.path] 
      cmd.extend(self.command_line_args()) 
      self.process = subprocess.Popen(cmd, env=self.env, 
              close_fds=platform.system() != 'Windows', 
              stdin=self.log_file, stdout=self.log_file, stderr=self.log_file) 

mit pyinstaller Recreated fehlte:

pyinstaller -F --noconsole -i favicon.ico Test.py 

Dies erstellt die exe aber jetzt das Konsolenfenster erschien ....

Python program with selenium(webdriver) Don't Work as single and noconsole exe file (pyinstaller)

+0

Vielleicht können diese Ihnen helfen: https://stackoverflow.com/questions/33867183/python-program-with-seleniumwebdriver-dont-work-as-single-and-noconsole-exe- f Scheint zum Thema zu sein ... –

Antwort

0

nach einiger Suche habe ich die vollständige Lösung gefunden: gehen Zum einen zu -

C:\Python35\Lib\site-packages\selenium\webdriver\common\service.py 

Wechsel:

self.process = subprocess.Popen(cmd, env=self.env, 
              close_fds=platform.system() != 'Windows', 
              stdout=self.log_file, stderr=self.log_file) 

An:

self.process = subprocess.Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=False, creationflags=0x08000000) 

jetzt einfach bauen deine Apppy wie folgt aus:

pyinstaller --noconsole --onefile --noupx Yourfile.py 
Verwandte Themen