Solution
The
os.path.abspath(<relative path>) function in Python interprets the relative path as being relative to the current working directory (CWD).
When calling the Python script from the Windows Command Promt, the CWD is normally the same as the Python script file's location. Consequently, the generated file paths defined relative to the CWD also becomes relative to the Python script file.
When the Python script is called using LabVIEW, the CWD is per default the directory from which LabVIEW has first been launched. I.e. if you open the LabVIEW from the
Start Menu the CWD will be
C:\Windows\System32, as observed.
There are two ways to approach this:
- Edit the Python script to refer to the script file location instead of the CWD when defining relative paths.
- Programmatically change the CWD from LabVIEW.
There is an example VI that can be used as a subVI to get or set the CWD from LabVIEW. Thus if the CWD is set before calling the Python script, one can decide what directory the relative paths should be relative to.