UiPath Documentation
activities
latest
false
开发者活动
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。

已知问题和限制

Solutions for known issues when running Python scripts with the Python activity package, including thread, file path, and type conversion problems.

The following behaviors are worth knowing when you run Python scripts with the Python activity package. Each one includes a workaround.

Scripts run on a background thread​

Symptom: A script fails with the following error, typically while importing a library that installs signal handlers, such as xlwings or another Excel or GUI bridge:

ValueError: set_wakeup_fd only works in main thread of the main interpreter

Cause: Code inside a Python Scope runs on a worker thread, not on the process main thread, so Python code that requires the main thread fails.

Action: Use one of the following approaches:

  • Prefer libraries that do not require the main thread, for example openpyxl or pandas instead of xlwings for reading and writing Excel files.
  • Run the main-thread-sensitive code in a separate Python process, launched with subprocess and pointed at a real Python executable, such as the one returned by shutil.which("python3").

Inside the activity, sys.executable points to the host process rather than to your Python interpreter, so it is not a valid target for subprocess.

Relative file paths resolve against an unexpected folder​

Symptom: A relative path such as open("data.csv") reads from or writes to a location you did not intend, and the file appears to be missing.

Cause: When the WorkingFolder property is not set, the working directory of the running script is the activity's own runtime folder, not your project folder.

Action: Use one of the following approaches:

  • Set the WorkingFolder property of the Python Scope activity to the folder your script should run in.
  • Call os.chdir(...) at the start of your script.
  • Use absolute paths for file access.

Get Python Object cannot convert every Python type​

Symptom: The Get Python Object activity fails with the following error:

Get Python Object: Error converting Python object

Cause: The activity converts a Python return value into a .NET type. Complex or native Python objects, for example a dict, a list, or a pandas DataFrame, cannot always be converted.

Action: Return a string from your Python function and convert it in your workflow:

  1. In Python, serialize the value to JSON with json.dumps(...), or with df.to_json(orient="records") for a pandas DataFrame.
  2. Retrieve the value with Get Python Object as a String.
  3. Deserialize it in your workflow.

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新