Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.

Error in Python interpreter: Type: <class 'SyntaxError'> Value: EOL while scanning string literal (<string>, line 1) Line: <not available> Namespace: <not available> File: <not available>  #189

@Klodovsky

Description

@Klodovsky

I've been trying to run jpy on a Coldfusion server which is written in Java, at first the server just kept crashing whenever I run PyLib.startPython([]); , I kept trying and I think it worked since PyLib.isPythonRunning() switched from NO to YES.

In the other hand I'm getting a Python interpreter SyntaxError which could be a bug :

here's the stacktrace :

java.lang.RuntimeException: Error in Python interpreter:
Type: <class 'SyntaxError'>
Value: EOL while scanning string literal (, line 1)
Line:
Namespace:
File:
at org.jpy.PyLib.executeCode(Native Method)
at org.jpy.PyObject.executeCode(PyObject.java:88)
at org.jpy.PyObject.executeCode(PyObject.java:59)
at jdk.internal.reflect.GeneratedMethodAccessor116.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at coldfusion.runtime.java.JavaProxy.invoke(JavaProxy.java:106)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:4239)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:4202)
at cftest22ecfm1709273233.runPage(/opt/ColdFusion2021/cfusion/wwwroot/test2.cfm:40)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:257)
at coldfusion.tagext.lang.IncludeTag.handlePageInvoke(IncludeTag.java:749)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:578)
at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:605)
at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:43)
at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:162)
at coldfusion.filter.IpFilter.invoke(IpFilter.java:45)
at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:30)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:97)
at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:81)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:60)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62)
at coldfusion.CfmServlet.service(CfmServlet.java:232)
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:311)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:46)
at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:47)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at coldfusion.inspect.weinre.MobileDeviceDomInspectionFilter.doFilter(MobileDeviceDomInspectionFilter.java:57)
at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:47)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:359)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1589)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)

And the Coldfusion code :

<cfobject action=create type=java class=org.jpy.PyInputMode name=JpyPyInputMode> 
<cfobject action=create type=java class=org.jpy.PyLib name=JpyPyLib> 
<cfobject action=create type=java class=org.jpy.PyObject  name=JpyPyObject>

<cfobject action=create type=java class=java.io.FileInputStream  name=JavaFileInputStream>
<cfobject action=create type=java class=java.io.IOException name=JavaIOException>
<cfobject action=create type=java class=java.lang.System  name=JavaSystem>
<cfobject action=create type=java class=java.util.Properties  name=p>
<cfscript>
props = createObject("java","java.util.Properties");
inputStream = createObject("java","java.io.FileInputStream").init(expandPath("jpyconfig.properties"));
props.load(inputStream);
propertyKey1="jpy.pythonExecutable";
propertyValue1="/usr/bin/python3";
propertyKey2="jpy.pythonLib";
propertyValue2="/usr/lib/x86_64-linux-gnu/libpython3.8.so";
propertyKey3="jpy.jdlLib";
propertyValue3="/usr/local/lib/python3.8/dist-packages/jdl.cpython-38-x86_64-linux-gnu.so";
propertyKey4="jpy.jpyLib";
propertyValue4="/usr/local/lib/python3.8/dist-packages/jpy.cpython-38-x86_64-linux-gnu.so";
propertyKey5="jpy.pythonPrefix";
propertyValue5="/usr";

JavaSys=createObject("java","java.lang.System");
JavaSys.setProperty(propertyKey1,propertyValue1);
JavaSys.setProperty(propertyKey2,propertyValue2);
JavaSys.setProperty(propertyKey3,propertyValue3);
JavaSys.setProperty(propertyKey4,propertyValue4);
JavaSys.setProperty(propertyKey5,propertyValue5);



JpyPyLib.startPython([]);
writeDump(JpyPyLib.isPythonRunning());
writeDump(JpyPyLib.getPythonVersion());
JpyPyObject.executeCode("print('Hello from python \')", JpyPyInputMode.SCRIPT);
JpyPyObject.executeCode("print('Exemple Pandas : \')", JpyPyInputMode.SCRIPT);
JpyPyObject.executeCode("import sys,pandas as pd", JpyPyInputMode.SCRIPT);
//JpyPyObject.executeCode("pays = {\"region\": [\"Paris\", \"Grenoble\"]}", JpyPyInputMode.SCRIPT);
//JpyPyObject.executeCode("tab = pd.DataFrame(pays)", JpyPyInputMode.SCRIPT);
JpyPyObject.executeCode("print(sys.version)", JpyPyInputMode.SCRIPT);

</cfscript>

PS: createObject is Coldfusion's way of importing libraries/objects ( similar to import in java).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions