[python] pyinstaller chromedriver 콘솔창 제거

2021. 8. 2. 17:05python



336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

selenium을 사용하기 위해 chromedriver를 프로젝트내에 패킹했고,

경로 잡아주고 실행이 되는 것을 확인 했다.

그래서 pyinstaller --noconsole 옵션도 주고

webdriver 옵션에

options.add_experimental_option('excludeSwitches', ['enable-logging']) 도 줘봤고..

options.add_argument("--headless")
options.headless = True 도 설정해봤는데 계속 뜨네????

google에 답이 있기에 추가로 검색 되도록 남깁니다.

 

파이참에서 shift 두번 누르면 All 검색이 가능하다

service.py로 검색해보면

webdriver\common 으로 끝나는 파일이 보이는데 열어서

 

아래와 같은 부분 찾아서 stdin=PIPE 뒤에 comma 찍고 

[creationflags=0x08000000] <- 추가해주면 된다.

 

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

 

이걸로도 안된다면 

 

C:\Users\[사용자]\AppData\Local\Programs\Python\Python37\Lib\site-packages\selenium\webdriver\common\service.py 열어서 

 

똑같이 

 

  creationflags=0x08000000 

 

추가해주면 됩니다.

 

그 뒤에 다시 pyinstaller 해주면 console창은 안보인다 +_  +