pyinstaller 실행파일 콘솔창 안뜨게하기
1. pyinstaller로 실행 파일 생성
2.생성된 *.spec 파일 수정
console=True, 를 console=False, 로 수정하고 저장합니다.
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='camfit',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
Webdriver 콘솔창 안뜨게하기
pyinstaller 실행파일 생성 후 spec 파일내용을 수정해도 Webdriver를 실행하게되면 콘솔창이 뜹니다.
service.py 파일을 수정하면 콘솔창을 안뜨게 할 수 있습니다.
1. service.py 파일 경로
"~\Site-packages\selenium\webdriver\common\service.py"
2. service.py 파일 수정
creationflags=self.creation_flags, 를 creationflags=0x08000000, 로 수정하고 저장합니다.
def _start_process(self, path: str) -> None:
"""Creates a subprocess by executing the command provided.
:param cmd: full command to execute
"""
cmd = [path]
cmd.extend(self.command_line_args())
close_file_descriptors = self.popen_kw.pop("close_fds", system() != "Windows")
try:
self.process = subprocess.Popen(
cmd,
env=self.env,
close_fds=close_file_descriptors,
stdout=self.log_file,
stderr=self.log_file,
stdin=PIPE,
creationflags=0x08000000,
**self.popen_kw,
)
logger.debug(f"Started executable: `{self._path}` in a child process with pid: {self.process.pid}")
except TypeError:
raise
except OSError as err:
if err.errno == errno.ENOENT:
raise WebDriverException(
f"'{os.path.basename(self._path)}' executable needs to be in PATH. {self.start_error_message}"
)
if err.errno == errno.EACCES:
raise WebDriverException(
f"'{os.path.basename(self._path)}' executable may have wrong permissions. {self.start_error_message}"
)
raise
except Exception as e:
raise WebDriverException(
f"The executable {os.path.basename(self._path)} needs to be available in the path. {self.start_error_message}\n{str(e)}"
)
위 내용을 다수정하고 pyinstaller로 *.exe 파일을 다시 생성하면됩니다.