UiPath / Community.Activities

Repository of Windows Workflow Foundation Activities for UiPath Community
https://www.uipath.com/community
234 stars 139 forks source link

Python: importing other local Python files does not work when running a Python method through UiPath #43

Closed andumorie closed 4 years ago

andumorie commented 5 years ago

Describe the bug If you import a function from another Python file and use the Load Script activity, UiPath throws this exception: "ModuleNotFoundError : No module named 'to_import'"

To Reproduce Steps to reproduce the behavior:

  1. Create a Python file that imports and calls a function from another local Python file
  2. Running that Python script through the command line works as expected
  3. Running that same Python script through UiPath Load Script gives the above exception

Expected behavior It should import the function and run it without any problem, just like from the command line.

Additional context Example workflow here: https://drive.google.com/open?id=110ZaUyYRcYuUv5y6pvP0SKO8OcLgo2bw

Krogsager commented 5 years ago

Seconded. I made a post at https://forum.uipath.com/t/python-source-file-cannot-be-found/105883 but was directed to post here on github:

Scenario:

"Load Python Script" activity has issues at runtime. The standard attribute __file__ is not being assigned.

Steps to reproduce:

Create Python scope. Load Python Script. script.py:

print(f"__file__ = {__file__}")

Current Behavior:

Returns: __file__ = none

Expected Behavior:

__file__ = C:\Users\username\UiPath\project_name\script.py

Studio/Robot/Orchestrator Version:

Last stable behavior: N/A Last stable version: 2018.4.5 Enterprise OS Version: Win10 Pro 64-Bit

Others if Relevant: (workflow, logs, .net version, service pack, etc):

Python 3.6.8 Anaconda Inc. 64-bit

andumorie commented 4 years ago

This issue was fixed in package version 1.0.7053.27728 with the addition of the Working Folder property of the Python Scope activity. Setting the Working Folder property to the current directory now allows other local Python files/modules to be imported.

tg970 commented 4 years ago

Hi @andumorie - I'm running the package version 1.1.6863.33404 the 'WorkingFolder' input property has disappeared from the Python Scope activity. When I downgraded to the 1.0.7053.27728 version, it's there. Any idea why, or how, that addition was missed in the version bump?

Thanks!