I use Spyder for writing and compiling my python code and same I did with your code. I have not yet run your code but I will tell you at what step I would.
--> error: pynput not installed
--> fixed it by installing the same pynput and "import pynput" runs flawlessly
Downloaded the Sensor Node Free app from playstore
--> Opened it, clicked on the option "stream"
--> it then asked me 2 options: 1.) Stream live data(XML) and 2.) Stream live data(MQTT)
--> I clicked on the 1st one, then I checked the boxes for Accelerometer and Light Intensity.
--> Asked for Target IP Address: I filled my Laptop's IP Add. by looking it up through the command "ipconfig" in CMD.(Note: My laptop is sharing internet with my mobile through it's[ mobile's ] hotspot service.)
--> Asked for Port number, I filled 5555 but the thing to note is I modified the value of ip and port in your py program according to what I entered in that android app.
Clicked on the activate stream button in the app
Then ran your program in Spyder IDE but nothing happened !
Please help me !