I am trying to code using python on the Edison (from the IOT XDK).
I can run the classic "hello World" using python from the command line; however I cannot make it work from within a script. I know it seems simple to most but I am pulling my hair out.
Here is my script file:
print("Python running on Edison")
I get the following after saving and downloading to Edison:
| Intel (R) IoT - NPM Install - (may take several minutes)
npm WARN package.json SimpleTest@0.0.0 No description
npm WARN package.json SimpleTest@0.0.0 No repository field.
npm WARN package.json SimpleTest@0.0.0 No README data
| NPM INSTALL COMPLETE![ 0 ] [ 0 ]
Intel XDK - Message Received: run
=> Stopping App <=
ERROR: print("Python running on Edison")
ERROR: ReferenceError: print is not defined
at Object. (/home/root/.node_app_slot/main.py:2:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
I get the feeling that I am not really executing the script with python, but have no idea. If I insert a comment line (# ) as the second line, that line show up with the error.
Any help would be appreciated.
Thank you Mahan and Diego,
I am using the IOT XDK and yes, I did try to run the python script from the XDK interface. This is the way I have ben testing my node.js scripts and all seems to work when I do this. I was under the impression that I could create code for any of the supported languages (including python) and execute them the same way during debugging.
I do not understand all of the additional detail after the "ReferenceError", but I suppose it is trying to tell me exactly where the command failed.
I mentioned that the error seems to indicate that an interpreter other than python is looking at the script. Just my feeling since it is such a simple script. I thought that the hashbang (line 1) code was supposed to tell the system which interpreter to use on the script. I still seem to be misunderstanding something if the XDK cannot run this script.
I really only selected python to use as I have seen various code snippits that deal with Bluetooth using python to automate device selection.
Thanks again fro your quick responses,
But you surely can run your Python scripts on the target and communicate with XDK Node.JS code