Hey guys, there is a problem when I am trying to run a file in UiPath, with a python file, the file runs without problem, but a certain point of execution, the python file does not run and freezes, but when I stop the process in UiPath the python file keeps running, like magic and it completes the process, but I have to stop the process in UiPath
UiPath Python freezes coz it spawns a separate python.exe process that doesn’t stop with UiPath.
When you hit stop, UiPath kills its part but Python keeps chugging in background till done.
Quick fix: Kill lingering python.exe in Task Manager before run > Test script alone in cmd/PyCharm first > Use Load Python Script + Invoke Method (not direct file) > Add prints/try-catch in Python to spot hangs > Wrap in Try Catch + Terminate Workflow. Update UiPath.Python.Activities package too.
UiPath freezes because it launches Python as a separate python.exe process. When the script blocks or produces large output, UiPath waits forever, but python.exe continues running in the background. When you press Stop, UiPath stops but Python keeps running and finishes normally.
Fix it by using Load Script + Invoke Method, reducing returned data, add logs in Python, upgrade the Python package, and killing leftover python.exe before re-running.
If this helped you fix the problem, please mark as solution so it can help others too
This happens because UiPath is waiting for Python to return a response, but your Python script is still running in the background, and UiPath thinks it is “blocked”.
Try this-
Add this at the top of the script.
import sys
sys.stdout = open(sys.devnull, ‘w’)
Also, always return something from the method.
call this using:
Python Scope
Load Script
Invoke Python Method: main
Lastly, Do NOT use Run Python Script for long processes
Instead, wrap everything inside a function and call it with Invoke Python Method.