- Información general
- Criptografía
- Base de datos
- Java
- Python
- WebAPI
Problemas conocidos y limitaciones
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
openpyxlorpandasinstead ofxlwingsfor reading and writing Excel files. - Run the main-thread-sensitive code in a separate Python process, launched with
subprocessand pointed at a real Python executable, such as the one returned byshutil.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:
- In Python, serialize the value to JSON with
json.dumps(...), or withdf.to_json(orient="records")for a pandasDataFrame. - Retrieve the value with Get Python Object as a
String. - Deserialize it in your workflow.