티스토리 뷰

반응형

기존코드

..............................................

encoding='utf-8'

 이게 해답일까?

결과적으로 해결한 방법은 이것이었다.

이것 찾는데, 3일 걸린것 같다...

알고나니 허무하네요~ 여러분도 혹시 해메는 사람이 있을까해서.. 올려봅니다.

100번은 시도해본 것 같아요~

별의별 수정을 다했는데.. 결국 찾아서 기쁩니다.

오류없이 잘되네요~

 

 

 

        
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')    
if __name__ == '__main__':
    main()
    sys.exit()

 

100번 넘게 만났던 오류메시지 아니 경고메시지라고 해야 맞을 것 같네요~

C:\python\dist\jamb_ver9\_internal\excel\자동작도 유형별 데이터.xlsm
환영합니다! 프로그램을 실행합니다.
Exception in thread Thread-1 (_forward_stdout):
Traceback (most recent call last):
  File "threading.py", line 1016, in _bootstrap_inner
  File "threading.py", line 953, in run
  File "gooey\gui\processor.py", line 70, in _forward_stdout
  File "gooey\gui\processor.py", line 84, in _extract_progress
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 41: invalid start byte

 

 

 

수정후 코드

class ProcessController(object):
    # ... [이전 코드 유지] ...

    def _forward_stdout(self, process):
        '''
        Reads the stdout of `process` and forwards lines and progress
        to any interested subscribers
        '''
        while True:
            line = process.stdout.readline()
            if not line:
                break
            try:
                decoded_line = line.decode(self.encoding, errors='replace')
                _progress = self._extract_progress(decoded_line)

                pub.send_message(events.PROGRESS_UPDATE, progress=_progress)
                if _progress is None or self.hide_progress_msg is False:
                    pub.send_message(events.CONSOLE_UPDATE, msg=decoded_line)
            except UnicodeDecodeError as e:
                print(f"디코딩 오류: {e}")
        pub.send_message(events.EXECUTION_COMPLETE)

    # ... [나머지 코드 유지] ...

반응형
댓글