Skip to main content

Hi,

I am trying to re-use a python script (saved as .py file), so that i do not have to edit all my workspaces that contain this script in a private parameter.

I tried to follow the steps in

 https://knowledge.safe.com/articles/976/how-can-i-modularize-my-python-code.html

whereby I included a couple of codes within the python startup script something like below:

when I try referring the SetReader module in a private parameter, I get an error that says 'ImportError: No module named SetReader'

Can I please get some help regarding re-using python scripts ?

Thanks very much

import sys sys.path.append(r'\\fmeserver\Functions') 
import SetReader

Have a look here: http://stackoverflow.com/questions/4383571/importing-files-from-different-folder-in-python

The most important thing is that the entry you add to the Python path needs to be absolute.

You might also want to familiarize yourself with the __init__.py convention: http://stackoverflow.com/questions/448271/what-is-init-py-for


Have a look here: http://stackoverflow.com/questions/4383571/importing-files-from-different-folder-in-python

The most important thing is that the entry you add to the Python path needs to be absolute.

You might also want to familiarize yourself with the __init__.py convention: http://stackoverflow.com/questions/448271/what-is-init-py-for

Thanks. The 1st link was of good help !

 

 


Reply