← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #303256]: How to use relative path in Sikuli to load another python script

 

Question #303256 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/303256

    Status: Open => Answered

RaiMan proposed the following answer:
Ok, understood.

I do not understand "relative path"? relative to what?

In Python imported modules must either be stored in predefined standard
locations, whose paths are on sys.path automatically (like the site-
packages folder) or you have to add the absolute paths to sys.path at
runtime.

So if you want to achieve your goal, to use relative paths, you need some convention, that can be evaluated to absolute paths at runtime using the standard Python path features or SikuliX path features (http://sikulix-2014.readthedocs.io/en/latest/scripting.html#file-and-path-handling-convenience-functions)
- a folder xyz in the user's home folder
- a folder xyz in the current working dir
- a base folder.that is given in the environment 
- ... whatever

another option might be one of these:
http://sikulix-2014.readthedocs.io/en/latest/scenarios.html#access-python-packages-from-sikulix-scripts-run-by-sikulix-gui-or-commandline

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.