I am developing a quiz application in node.js. I need some python script to keep log of user,so I want to use key logger to keep monitoring the user while attempting the quiz. Here is the python keylogger script:
from pynput.keyboard import Key, Listener
import logging
log_directory = r"G:/Pythonin Node/Keylogger/key_logger/public/log_files/"
logging.basicConfig(filename = (log_directory+"keylog.txt"), level = logging.DEBUG)
def on_press(key):
logging.info(str(key))
with Listener(on_press = on_press) as listener:
listener.join()
Script working well when i run it in pycharm.but when I call it from node application using python-shell I found an error:
{
traceback: "Traceback (most recent call last): File "script.py", line 1, in <module> from pynput.keyboard import Key, Listener ModuleNotFoundError: No module named 'pynput' ",
executable: "py",
options: null,
script: "script.py",
args: [
"xyz",
"abc"
],
exitCode: 1
}
This is the simple json response.
Here is my node code:
app.get('/', callD_alembert);
function callD_alembert(req, res) {
var x="xyz";
var y="abc";
var options = {
args:
[
x,
y
]
}
PythonShell.run('./script.py', options, function (err, data) {
if (err) res.send(err);
res.send(data.toString())
});
}
python shell executes the simple python script in which I don't use any external package.but when I to use "pynput" package and want to import it.it gives the following error:
Here is also running a python interpreter:
please help me to solve this issue.
Thank you