1 version of incompatible problems
2 MAC jypthon didn't installed in terminal input jython, no reaction
3 eclispse isn't set up less what, especially on the compiler
Properties props=new Properties();
Props. The put (python. The console. "encoding", "utf-8");
Props. The put (" python. Security. RespectJavaAccessibility ", "false");
Props. The put (python. Import. "site", "false");
The Properties of preprops=System. The getProperties ();
PythonInterpreter. The initialize (preprops, props, new String [0]).
PythonInterpreter interpreter=new PythonInterpreter ();
Interpreter. The exec (" import sys ");
Interpreter. The exec (" sys. Path. Append ('/Users/zhong/jython2.7.0/Lib ') ");//jython own
Interpreter. The exec (" sys. Path. Append ('/Users/zhong/jython2.7.0/Lib/site - packages') ");//load jython script Python jar package
Interpreter. Execfile ("./pythonProfile getPython1. Py ");
PyFunction func=(PyFunction) interpreter. Get (" adder, "PyFunction. Class);
Int a=10, b=2;
PyObject pyobj=func. __call__ (new PyInteger (a), the new PyInteger (b));
System. The out. Println (" anwser="+ pyobj. ToString ());
the Exception in the thread "is the main" Java. Lang. IllegalArgumentException: always create a PyString with non - byte value
The at org. Python. Core. PyString. & lt; init> (PyString. Java: 64)
The at org. Python. Core. PyString. & lt; init> (PyString. Java: 70)
The at org. Python. Core. PySyntaxError. & lt; init> (PySyntaxError. Java: 33)
The at org. Python. Core. ParserFacade. FixParseError (ParserFacade. Java: 95)
The at org. Python. Core. ParserFacade. Parse (ParserFacade. Java: 190)
At org.python.core.Py.com pile_flags (Py. Java: 1956)
The at org. Python. Core. __builtin__. Execfile_flags (__builtin__. Java: 527)
The at org. Python. Util. PythonInterpreter. Execfile (PythonInterpreter. Java: 286)
The at test1. Python_Java. Main (Python_Java. Java: 46)
Looking at online call is successful, I here is not used, the
CodePudding user response:
Java is a unicode string inside, python to byte stringCodePudding user response: