From 65452ac009cad81e77ff8488565adb602ad659b3 Mon Sep 17 00:00:00 2001 From: Hk669 Date: Tue, 3 Sep 2024 13:59:50 +0530 Subject: [PATCH] fix picked from autogen --- autogen/coding/local_commandline_code_executor.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/autogen/coding/local_commandline_code_executor.py b/autogen/coding/local_commandline_code_executor.py index ca9ecdf745b2..8a2ad541d6a5 100644 --- a/autogen/coding/local_commandline_code_executor.py +++ b/autogen/coding/local_commandline_code_executor.py @@ -227,7 +227,12 @@ def _setup_functions(self) -> None: cmd = [py_executable, "-m", "pip", "install"] + required_packages try: result = subprocess.run( - cmd, cwd=self._work_dir, capture_output=True, text=True, timeout=float(self._timeout) + cmd, + cwd=self._work_dir, + capture_output=True, + text=True, + timeout=float(self._timeout), + encoding="utf-8", ) except subprocess.TimeoutExpired as e: raise ValueError("Pip install timed out") from e @@ -309,7 +314,13 @@ def _execute_code_dont_check_setup(self, code_blocks: List[CodeBlock]) -> Comman try: result = subprocess.run( - cmd, cwd=self._work_dir, capture_output=True, text=True, timeout=float(self._timeout), env=env + cmd, + cwd=self._work_dir, + capture_output=True, + text=True, + timeout=float(self._timeout), + env=env, + encoding="utf-8", ) except subprocess.TimeoutExpired: logs_all += "\n" + TIMEOUT_MSG