Python source file cannot be found

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

Hi @Tiramisu

Any chance you could provide a sample project? Feel free to simply create a new project and zip it’s entire folder for us to investigate :slight_smile:
That’s the quickest way for us to replicate the behavior.

Also, please keep in mind that some packages were “outsourced” to the community via our GitHub and Python activity pack is one of those:

Therefore, you might want to log an issue over there or even contribute directly to fixing it :slight_smile:

1 Like

Following an existing thread here:

For anyone looking for a workaround until this issue is fixed, you can do sys.path.append with a hard-coded reference to the project dir.

my_python.py

import sys
sys.path.append('C:/Users/username/UiPath/project_folder')
import my_class
2 Likes

Hello,

UIPath Rookie here. I am not sure if mine is a similar (or related) problem.

When using the Load Python Scripts Activity it fails whenever I have an import statement. I’m trying to import Pandas and BeautifulSoup. But it works fine when I remove them.

Kindly assist. Thanks.