Hi ~Salvatore Sanfilippo, We are executing Redis script which is given in the Phython script, to execute we are using Jython library's PythonInterpreter class and we are always getting the following error.
Sample Code:
public static void main(String[] args) {
try {
Properties properties = new Properties();
properties.setProperty("python.home", "../jython2.7.1/");
properties.setProperty("python.path", "../jython2.7.1/Lib");
properties.setProperty("python.import.site", "false");
PythonInterpreter.initialize(System.getProperties(), properties, new String[] {""});
PythonInterpreter python = new PythonInterpreter();
String script = "import sys\n" + "sys.path.append(\"../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();
}
}
Error after execution:
Traceback (most recent call last):
File "<string>", line 4, in <module>
ImportError: No module named redis
I have posted the same requirement with Jython community as well. References: https://bugs.jython.org/issue2818 https://bugs.jython.org/issue2816 Can you please look into it and give a suggestion how to handle the same. Please let me know if you need any more details to resolve this issue.
Thanks in advance. RK
Comment From: itamarhaber
Hello @rkanumola
Keep in mind that this issue tracker should be used for reporting bugs or proposing improvements to the Redis server. The above appears totally unrelated to the Redis project and appears to be a Pythonic error (perhaps you didn't pip install redis?).
Comment From: rkanumola
Thanks @itamarhaber for the response.
We raised the issues at the concerned forum as well. Just in case if you come across any of these issues from other customers which might help us is the intention.
pip install redis did not help .
Comment From: divakaru
Hi @rkanumola, is the above issue resolved? I'm also facing the same error, can you plz assist me on this