Python 作用域错误——重新安装后仍提示“指定的 Python 路径无效”

大家好,

我目前正在使用 UiPath Studio(社区版)开发一个自动化项目,需要通过 Python Scope 活动运行 Python 脚本。但我一直遇到以下错误:

Python Scope: 指定的 Python 路径无效:C:\Program Files\Python39\python.exe

目前我尝试过以下方法:

  • 安装并重新安装了多个 Python 版本(3.10、3.12、3.9),均为 64 位版本
  • 确认可以从该路径手动打开 python.exe
  • 按照安装目录中显示的路径,在 UiPath 中设置了 Python 路径
  • 重启了 UiPath 和笔记本电脑
  • 确保 Python 已添加到 PATH,并且 pip 可以正常运行
  • 编写了一个简单脚本,确认它可以在 VS Code 或终端中运行

尽管尝试了以上所有方法,Python Scope 活动仍然无法识别该 Python 路径。

:light_bulb: 我需要用 Python Scope 运行一个 Prophet 时间序列预测脚本,以预测 2025 年的客户交易情况,并计划将输出集成到 UiPath 中的其他自动化流程。

如果能得到任何帮助,我将不胜感激。先谢谢大家!

Hi @nashwasabila11

Please have a look at this sample:

There is a sample project at the bottom of the page with a sample configuration. Could you please double-check your configuration against this sample ?

@nashwasabila11

are you providing the apth to exe or the folder containing exe? you need to only pass till the folder

cheers

Thanks a lot for your help! :folded_hands:
The path issue is now resolved after I updated it as you suggested. :blush:

However, I’m now getting a new error:
“Python Scope: Error initializing Python engine”

Looks like it’s a different issue — maybe related to the Python version or environment. I’ll dig into it a bit more and see what I can find.

Really appreciate your support! :raising_hands:

@nashwasabila11

glad it is resolved

try to check the event viewer log it might show the error can be related to .net runtime version

cheers

Thank you so much for your attention and support — really appreciate it! :folded_hands:
I’ll definitely take a closer look at the sample project and compare it with my current configuration.

Thanks again for guiding me through this! :blush:

Hi again, thanks for the previous help — I initially thought it was resolved, but I’m still facing an issue.

I did what you suggested:

  • I opened Event Viewer
  • I downloaded and installed the appropriate .NET Runtime as needed

However, now when I try to run the workflow, I’m getting this error again:

“Invoke Python Method: One or more errors occurred. (Error invoking Python method)”

Just to confirm:

  • I’m loading the Python script via Load Python Script with the File path , and leaving the Code field empty
  • Using Python 3.X with pandas installed
  • The Python function returns a pandas DataFrame — could that be causing an issue?

I’m wondering if this is still related to the .NET Runtime or maybe how the return value is handled?

Any ideas would be greatly appreciated — thank you again!

@nashwasabila11

  1. Open the exception detaila from locals pane by running in debug mode to check the full error that might give correct issue
  2. First try to run a simple python script with no imports and simple code like addition of number or so to check if setup is proper
  3. As per error looks like the return or import is failing ..import might fail if library path is not provided or if there are multiple instances of python

Cheers

Thanks for your help! Really appreciate you taking the time to guide me — it worked in the end!