I cant work with Python Scope

Hello Everyon
I want to run a very simple python file from UiPath.

Print(“Hello world”)

I have tried a lot but it does not work!

One time, I selected the run python script activity inside a python scope activity.
Another time, I tried to make a function first. Then make a load python script activity. Then, Invoke Python activity. Then, Get Python object, Then, Message box.

However, this idea did not work for me as well.

Does anyone know how can I make an integration between python and UiPath ?

@Seyedhossein_AKRAMI

Welcome to the community

First of all are you getting any error or is it stuck?

Did you install .net runtime 5.0?

Please check for example here

Cheers

@Anil_G Thank you for your reply!
No, there is no error. The problem is that my python code does not execute!

@Seyedhossein_AKRAMI,

I hope you have install Python and .Net runtime 6 as prerequisite.

Python versions supported:

.Net Runtime

Thanks,
Ashok :slight_smile:

@Seyedhossein_AKRAMI

As mentioned already please check the .net runtime version

Cheers

Thank you for your reply!
I have installed the python as well as dotnet runtime 6 on my system. In addition, on the UiPath, the python acitivities is installed.

Is there any specific activity package in the UiPath, relating to the .Net, I need to install as well ?

Because, the code does not execute.

@Seyedhossein_AKRAMI,

Latest version would work. What’s the version of Python you have? Check this way.

image

Thanks,
Ashok :slight_smile:

@Seyedhossein_AKRAMI

Your script might be working but print(“Hello World”) will not give you an output in UiPath environment. For that you need to return a value from a function and call that function from UiPath.

For example:

Python Code -

def myFunc():
    return "Hello World"

→ Now inside UiPath Studio, use Python Container, inside the container call this python script using load python script activity.

→ Now in the load python script activity give the name of the function, i.e. “myFunc”.

→ Now use Get Python Object activity and set the type argument to System.String

The key point is inorder to get a value out of your python script in UiPath environment, you should return that value using a function.

Cheers

the version I have is:
Python 3.11.9

Yes, I understand your point. But even your idea does not work on my system

@Seyedhossein_AKRAMI,

Ok so it’s supported version. May I see the script?

Thanks,
Ashok :slight_smile:

Can you try running it in a Windows-Legacy project?

Yes, sure. How can I attach the screenshot here in this forum ?

@Seyedhossein_AKRAMI,

If it’s small script you can take screenshot by Snipping tool and directly paste in the reply text box otherwise you can click on Upload button to share files.

Thanks,
Ashok :slight_smile:


Ok, Thank you. I just shared the cmd to show you that my python and my .Net are both installed correctly on my system

This is my simple python code which just opens the cmd and maximize it on my screen.
I can run it by VSCODE, meaning that the code is correct. But, it does not execute from the UiPath.

import os

import subprocess

Open Command Prompt, maximize window, and wait for user input

Open Command Prompt

os.system(‘start cmd’)

subprocess.Popen(‘start /MAX cmd /K pause’, shell=True)

Recently, I also encountered this problem.

You try downgrading the package. python.activity is 1.4.1

@ashokkarale

Can you please help me with this issue ? Because I stucked and I need your help!

Thank you!