I have a (single) .py script. In it, I need to import a library.
In order for this library to be found, I need to call sys.path.append. However, I do not want to hardcode the path to the library, but pass it as a parameter.
So my problem is that if I make a function (set_path) in this file, I need to import the file, and import fails because the path is not yet appended.
What are good ways to solve this problem?
Clarification after comments:
- I am using IronPython, and the library path is the path to CPython/lib. This path is (potentially) different on every system.
- As far as I know, I cannot pass anything via sys.argv, because the script is run in an embedded python interpreter, and there is no main function.
PYTHONPATHenvironment variable instead of changingsys.path?