11-23-2023 06:13 AM
I've noticed that the python node is ignoring the file extension. I'm wondering if this is a bug or a feature...
This VI was running example.py. I chose example.sqc by mistake and noticed it was still returning the right value.
11-23-2023 06:29 AM
Hi lucian,
@lucian.grec wrote:
I've noticed that the python node is ignoring the file extension. I'm wondering if this is a bug or a feature...
This VI was running example.py. I chose example.sqc by mistake and noticed it was still returning the right value.
Why do you think it is a bug when the Python node executes the Python file that you provide with your filepath!?
("File extension" is just a concept for Windows to decide which executable might be appropriate to handle a certain file…)
11-23-2023 07:29 AM
Because example.sqc is a file that doesn't exist
11-23-2023 07:37 AM
Hi lucian,
@lucian.grec wrote:
Because example.sqc is a file that doesn't exist
You didn't say so in your first message…
11-24-2023 05:07 AM - edited 11-24-2023 05:11 AM
I honestly doubt that LabVIEW itself does this. LabVIEW is mostly file ending agnostic as far as the underlaying platform allows that and for instance will happily load a file with any ending as a VI as long as its internal file structure is indeed a VI.
Python as multiplatform application is also fairly file ending agnostics. And it seems that it even has a feature in the API, that LabVIEW uses to interface to the Python engine, and this feature tries to attempt to load a file with alternative file ending if it couldn't find the indicated file. Most likely this comes from the fact that you have both source and compiled files in Python with the ending .py and .pyc. This feature makes sure that even if the user specifies explicitly a pyc file, that it will still work when there is actually a py file in that location but no pyc file (or when loading of the pyc file failed because it is not in the same version as the current Python execution engine).
11-25-2023 12:54 PM
I assume it's the nipythonhost.exe that loads the file. In any case I'm not referring to a .pyc file here, it could even be a .xlsx and it'd still work as long as the .py with the right name exists at that location.
I'm not that well versed in python but trying to run a script from command line with python example.sqc instead of example.py seems to fail. I assume there are some flags then that you can call the python interpreter with that could take care of the name mismatch