autodeployai / pypmml

Python PMML scoring library
Apache License 2.0
76 stars 22 forks source link

Using a higher version of pypmml(>=1.0) to load a pmml model will result in an error #59

Open lchzh opened 3 weeks ago

lchzh commented 3 weeks ago

ValueError Traceback (most recent call last)

in ----> 1 Model.load("C034_M0000000188.pmml") ~/anaconda3/lib/python3.8/site-packages/pypmml/model.py in load(cls, f) 229 # Check if a file path 230 if os.path.exists(model_content): --> 231 model = cls.fromFile(model_content) 232 else: 233 model = cls.fromString(model_content) ~/anaconda3/lib/python3.8/site-packages/pypmml/model.py in fromFile(cls, name) 197 def fromFile(cls, name): 198 """Load a model from PMML file with given pathname""" --> 199 pc = PMMLContext.getOrCreate() 200 java_model = pc.call_java_static_func("org.pmml4s.model.Model", "fromFile", name) 201 return cls(java_model) ~/anaconda3/lib/python3.8/site-packages/pypmml/base.py in getOrCreate(cls, gateway, java_opts, java_path) 61 with PMMLContext._lock: 62 if PMMLContext._active_pmml_context is None: ---> 63 PMMLContext(gateway=gateway, java_opts=java_opts, java_path=java_path) 64 return PMMLContext._active_pmml_context 65 ~/anaconda3/lib/python3.8/site-packages/pypmml/base.py in __init__(self, gateway_instance, gateway, java_opts, java_path) 24 25 def __init__(self, gateway_instance=None, gateway="py4j", java_opts=None, java_path=None): ---> 26 PMMLContext._ensure_initialized( 27 self, 28 gateway_instance=gateway_instance, ~/anaconda3/lib/python3.8/site-packages/pypmml/base.py in _ensure_initialized(cls, instance, gateway_instance, gateway, java_opts, java_path) 38 with PMMLContext._lock: 39 if not PMMLContext._gateway: ---> 40 PMMLContext._gateway = gateway_instance or cls.launch_gateway( 41 gateway=gateway, java_opts=java_opts, java_path=java_path 42 ) ~/anaconda3/lib/python3.8/site-packages/pypmml/base.py in launch_gateway(cls, gateway, java_opts, java_path) 80 from .jvm import Py4jGateway 81 jvm_gateway = Py4jGateway() ---> 82 jvm_gateway.launch_gateway(java_opts=java_opts, java_path=java_path) 83 return jvm_gateway 84 ~/anaconda3/lib/python3.8/site-packages/pypmml/jvm.py in launch_gateway(self, java_opts, java_path) 167 super().launch_gateway(java_opts=java_opts, java_path=java_path) 168 if Py4jGateway._gateway is None: --> 169 _port = launch_gateway(classpath=self.classpath, javaopts=self.java_opts, java_path=self.java_path, die_on_exit=True) 170 Py4jGateway._gateway = JavaGateway(gateway_parameters=GatewayParameters(port=_port, auto_convert=True)) 171 Py4jGateway._jvm = Py4jGateway._gateway.jvm ~/anaconda3/lib/python3.8/site-packages/py4j/java_gateway.py in launch_gateway(port, jarpath, classpath, javaopts, die_on_exit, redirect_stdout, redirect_stderr, daemonize_redirect, java_path, create_new_process_group, enable_auth, cwd, return_proc, use_shell) 335 # Determine which port the server started on (needed to support 336 # ephemeral ports) --> 337 _port = int(proc.stdout.readline()) 338 339 # Read the auth token from the server if enabled. ValueError: invalid literal for int() with base 10: b''
scorebot commented 3 weeks ago

Based on the error message above, it seems the Java process not started successfully. Can you please check if the java command is in PATH or set the correct JAVA_HOME?

FRMer3737 commented 1 week ago

I also encountered this issue. Have you resolved it?

scorebot commented 1 week ago

@FRMer3737 Can you please provide the following info? OS, Python version, Java version, and pypmml vresion

FRMer3737 commented 1 week ago

@scorebot thanks for your rapid answer. python3.12.4;Java 1.8.0_333;pypmml 1.5.2; print(os.path.exists(r'br_fpd_model_2024.pmml')) is true

scorebot commented 1 week ago

@FRMer3737 What's your OS? Is the java command in PATH or setting the correct JAVA_HOME?

FRMer3737 commented 1 week ago

sorry,my os is windows and setting the correct JAVA_HOME

发自我的iPhone

------------------ Original ------------------ From: Bo Song @.> Date: Fri,Nov 1,2024 11:45 AM To: autodeployai/pypmml @.> Cc: FRMer3737 @.>, Mention @.> Subject: Re: [autodeployai/pypmml] Using a higher version of pypmml(>=1.0) to load a pmml model will result in an error (Issue #59)

@FRMer3737 What's your OS? Is the java command in PATH or setting the correct JAVA_HOME?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

scorebot commented 1 week ago

The root cause is Java 1.8 which doesn't support the option --add-exports=java.base/jdk.internal.math=ALL-UNNAMEDthat was added from pypmml>=1.0, the workaround is to upgrade your java to a new version, for example, Java 11. Actually, the latest pypmml doesn't depend on the option anymore, I will remove it in the next version soon

FRMer3737 commented 1 week ago

Thanks sooooooo much. I'll try it. 

发自我的iPhone

------------------ Original ------------------ From: Bo Song @.> Date: Fri,Nov 1,2024 0:28 PM To: autodeployai/pypmml @.> Cc: FRMer3737 @.>, Mention @.> Subject: Re: [autodeployai/pypmml] Using a higher version of pypmml(>=1.0) to load a pmml model will result in an error (Issue #59)

The root cause is Java 1.8 which doesn't support the option --add-exports=java.base/jdk.internal.math=ALL-UNNAMEDthat was added from pypmml>=1.0, the workaround is to upgrade your java to a new version, for example, Java 11. Actually, the latest pypmml doesn't depend on the option anymore, I will remove it in the next version soon

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

scorebot commented 1 week ago

@FRMer3737 @lchzh Fixed the issue in the pypmml 1.5.3

scorebot commented 4 days ago

@FRMer3737 @lchzh Please let me know if the new version 1.5.3 resolved your issue. Thank you.