LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Python node ignoring file extension

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.

image.png

0 Kudos
Message 1 of 6
(880 Views)

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…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(866 Views)

Because example.sqc is a file that doesn't exist

0 Kudos
Message 3 of 6
(843 Views)

Hi lucian,

 


@lucian.grec wrote:

Because example.sqc is a file that doesn't exist


You didn't say so in your first message…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(839 Views)

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).

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 6
(798 Views)

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

0 Kudos
Message 6 of 6
(749 Views)