# Problem with python script

**URL:** <https://forum.electroneek.com/t/problem-with-python-script/5052>\
**Category:** Studio Pro\
**Tags:** python\
**Created:** [September 21, 2024, 3:41am UTC](https://forum.electroneek.com/t/problem-with-python-script/5052 "2024-09-21T03:41:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oscar\_Gonzalez](https://forum.electroneek.com/user_avatar/forum.electroneek.com/oscar_gonzalez/32/1826_2.png) [@Oscar\_Gonzalez](https://forum.electroneek.com/u/Oscar_Gonzalez)\
**Post date:** [September 21, 2024, 3:41am UTC](https://forum.electroneek.com/t/problem-with-python-script/5052/1 "2024-09-21T03:41:27Z")

</div>

![imagen](https://forum.electroneek.com/uploads/default/original/2X/d/d183244f2b0d6158147a926db678bdbf99da92d9.png)

I got this error when tried to run a script through electroneek activity, Script runs fine on vscode. Variable mentioned “mostrar” is from a function that returns a value within the script  
Here is part of the script

 ![imagen](https://forum.electroneek.com/uploads/default/original/2X/f/fc338f02ab0721b549c35574acafdc9b6f9201b2.png)

---

<div class="post-metadata">

**Author:** ![Jorge\_RPA](https://forum.electroneek.com/user_avatar/forum.electroneek.com/jorge_rpa/32/746_2.png) [@Jorge\_RPA](https://forum.electroneek.com/u/Jorge_RPA)\
**Post date:** [October 3, 2024, 4:51pm UTC](https://forum.electroneek.com/t/problem-with-python-script/5052/2 "2024-10-03T16:51:33Z")

</div>

Hey Oscar,  
In this case, you must check how you send or declare the variables to the function. Attaching an example declaring the variable and value in the py code and also when sending the values from Studio Pro.  
[time2.zip](https://forum.electroneek.com/uploads/short-url/mm0mkDk7cpZdz8U2UTXVMNBUaZW.zip) (2.1 KB)

Best Regards

---

<div class="post-metadata">

**Author:** ![Oscar\_Gonzalez](https://forum.electroneek.com/user_avatar/forum.electroneek.com/oscar_gonzalez/32/1826_2.png) [@Oscar\_Gonzalez](https://forum.electroneek.com/u/Oscar_Gonzalez)\
**Post date:** [October 4, 2024, 2:22am UTC](https://forum.electroneek.com/t/problem-with-python-script/5052/3 "2024-10-04T02:22:18Z")

</div>

Thanks for the answer, but in my case the variable is only to operate in an internal process of the script it is not necessary to send it to Studio Pro, that is the reason for my question, it should not give error in electroneek about a variable that will not be used in the bot.

---

<div class="post-metadata">

**Author:** ![Jorge\_RPA](https://forum.electroneek.com/user_avatar/forum.electroneek.com/jorge_rpa/32/746_2.png) [@Jorge\_RPA](https://forum.electroneek.com/u/Jorge_RPA)\
**Post date:** [October 4, 2024, 12:53pm UTC](https://forum.electroneek.com/t/problem-with-python-script/5052/4 "2024-10-04T12:53:17Z")

</div>

Hi Oscar,  
In the attached neek file, I have sent you 2 examples. In one of them the variable is passed from Studio, in the other it is declared in the py code. The return to Studio Pro is optional.

---

<div class="post-metadata">

**Author:** ![Oscar\_Gonzalez](https://forum.electroneek.com/user_avatar/forum.electroneek.com/oscar_gonzalez/32/1826_2.png) [@Oscar\_Gonzalez](https://forum.electroneek.com/u/Oscar_Gonzalez)\
**Post date:** [October 19, 2024, 9:08pm UTC](https://forum.electroneek.com/t/problem-with-python-script/5052/5 "2024-10-19T21:08:17Z")

</div>

thanks Jorge\_RPA examples received, I’m going to test it

---

<div class="post-metadata">

**Author:** ![Naincy\_Casper](https://forum.electroneek.com/letter_avatar_proxy/v4/letter/n/ce73a5/32.png) [@Naincy\_Casper](https://forum.electroneek.com/u/Naincy_Casper)\
**Post date:** [April 10, 2026, 11:52am UTC](https://forum.electroneek.com/t/problem-with-python-script/5052/6 "2026-04-10T11:52:52Z")

</div>

I’ve run into similar issues before where the RPA environment handles local script variables differently than a standard IDE like VS Code. Even if you don’t need the variable in Studio Pro, sometimes explicitly initializing it at the top of your script or ensuring it’s clearly within the local scope of your function can help clear those ‘NameError’ or undefined variable messages. It seems like the activity might be trying to parse the script’s output a bit too strictly!
