I'm using PyInstaller to convert my Python file to .exe; however, I see that upon running the executable file, I don't see any print messages in the terminal which I use for my reference - it's just blank (no print messages).
Command I used: pyinstaller --onefile -w myfile.py
I use Selenium module in my Python file, which uses chromedriver.exe, so after running the generated .exe file, this is what it shows:
Code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.service import Service
from selenium.common.exceptions import TimeoutException
from time import sleep
import random
driver = webdriver.Chrome()
wait = WebDriverWait(driver, 20)
print("Opened the browser")
Pictures:
I need to see the print messages. Tried searching for answers but couldn't find any solutions!
How do I resolve this?
CodePudding user response:
If you run your .exe
from a terminal like PowerShell it will probably show the output you're looking for. The window in the screenshot looks like it is coming from the Selenium driver.
If you want this to work when double-clicking on the .exe
, rebuild without the -w
flag:
-w, --windowed, --noconsole
Windows and Mac OS X: do not provide a console window for standard i/o. On Mac OS this also triggers building a Mac OS .app bundle. On Windows this option is automatically set if the first script is a ‘.pyw’ file. This option is ignored on *NIX systems.