Skip to content

A programming framework for agentic AI

Use utf-8 encoding at subprocess.run() (#3454)

giorgossideris457752499436
diff --git a/autogen/coding/local_commandline_code_executor.py b/autogen/coding/local_commandline_code_executor.py
index 620b359a4..2280f7f03 100644
--- a/autogen/coding/local_commandline_code_executor.py
+++ b/autogen/coding/local_commandline_code_executor.py
@@ -221,7 +221,12 @@ $functions"""
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
@@ -303,7 +308,13 @@ $functions"""
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