'requested item "......" does not exist' I'm a new python/Blender user
I'm trying to move an object using an Arduino. I've watched many videos and tutorials, and somehow i could write a code using others codes.
here is my code 

import bge
import math
import serial



controller = bge.logic.getCurrentController()
own = controller.owner

serialport = serial.Serial('COM4', 9600)
sens = controller.sensors['run']


val1=0.0
val2=0.0
val3=0.0
p = pi/255

def run():
    if sens.positive: 
            serialport.write('s'.encode('ascii')) #blender sends the ascii code of "s" to the Arduino
            n = serialport.readline() #receive data from the arduino
            val1 = (float) (n)
            val2 = (val1-val3)* p
            val3 = val1
            print ('The value is: ')
            print (val2)
            own.applyRotation((0 , val2 , 0),0)

#    own.position.y = val2


my problem is with the sens = controller.sensors['run'] when i run the game engine the following message appears:

Python module can't be imported - object 'Cube', controller 'Python':
KeyError: 'requested item "run" does not exist'

as usual i looked for a solution by checking questions of people have the same problem here and elsewhere. so i followed some of the best answers. such as, setting the actor flag in physics tab, some people suggested that reinstalling blender would help. nothing worked for me.
thanks anyway
Analysis


  Python module can't be imported - object 'Cube', controller 'Python': KeyError: 'requested item "run" does not exist'


This means you misconfigured the Python controller.

Either you use script mode and you refer to an not existing text block called "run" (the field should have red background).

Or you use module mode and you did not mention what file contains your code.

E.g. your code is called arduino.py. You can set up this line: arduino.applyRotation. 

The BGE will look for arduino.py and check if it finds a function applyRotation.

arduino.py

import bge 

def applyRotation(controller):
    sensor = controller.sensors["run"]
    if sensor.positive:
        ...


Solution

Ensure the file and the function inside of it can be found.

Hint:

If you want to use the module mode ensure to retrieve the controller inside of the called function. Otherwise you get unwanted side effects.