|
From: RK <re...@bu...> - 2019-10-30 07:41:07
|
New submission from RK <ram...@gm...>:
We are using PythonInterpreter to interact of Redis script data which was invoked through Python script. And we are not able to import redis module and getting the folowing error. If the PythonInterpreter is not compatible with Redis module can you please check and give us this compatability .
Traceback (most recent call last):
File "<string>", line 4, in <module>
ImportError: No module named redis
Sample piece of code which give the above error:
public static void main(String[] args) {
try {
Properties properties = new Properties();
properties.setProperty("python.home", "/Users/ranumola/jython2.7.1/");
properties.setProperty("python.path", "/Users/ranumola/jython2.7.1/Lib");
properties.setProperty("python.import.site", "false");
PythonInterpreter.initialize(System.getProperties(), properties, new String[] {""});
PythonInterpreter python = new PythonInterpreter();
String script = "# Python3 program to add two numbers \n" + " \n" + "num1 = 15\n" + "num2 = 12\n" + " \n" + "# Adding two nos \n"
+ "sum = num1 + num2 \n" + " \n" + "# printing values \n" + "print(\"Sum of {0} and {1} is {2}\" .format(num1, num2, sum)) ";
String script1 = "import sys\n" + "sys.path.append(\"/Users/ranumola/jython2.7.1/Lib\")\n" + "\n" + "import redis\n"
+ "r = redis.Redis(host='localhost', port=6379)\n" + "r.get('foo')";
python.set("script", new PyString(script));
python.exec(script);
python.close();
} catch (Exception e) {
e.printStackTrace();
}
}
----------
components: Core, Library
messages: 12728
nosy: rkanumola
severity: normal
status: open
title: Support for Redis Module for PythonInterpreter
versions: Jython 2.7
_______________________________________
Jython tracker <re...@bu...>
<https://bugs.jython.org/issue2818>
_______________________________________
|