IllegalArgumentException: 'requirement failed: License Key not set please set environment variable JSL_OCR_LICENSE or property jsl.sparkocr.settings.license!'
ChicoQ opened this issue · 7 comments
License Key not set
The above exception occurs when I play with tutorials/Certification_Trainings/Healthcare/5.Spark_OCR.ipynb
- start running this notebook on colab
- uploading my licence key
- Spark NLP and Spark OCR are able to run correctly
- It is failed at this cell, result = pipeline().transform(pdf_example_df).cache()
Py4JJavaError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/pyspark/sql/utils.py in deco(*a, **kw)
62 try:
---> 63 return f(*a, **kw)
64 except py4j.protocol.Py4JJavaError as e:
7 frames
/usr/local/lib/python3.7/dist-packages/py4j/protocol.py in get_return_value(answer, gateway_client, target_id, name)
327 "An error occurred while calling {0}{1}{2}.\n".
--> 328 format(target_id, ".", name), value)
329 else:
Py4JJavaError: An error occurred while calling None.com.johnsnowlabs.ocr.transformers.PdfToImage.
: java.lang.IllegalArgumentException: requirement failed: License Key not set please set environment variable JSL_OCR_LICENSE or property jsl.sparkocr.settings.license!
at scala.Predef$.require(Predef.scala:224)
at com.johnsnowlabs.license.LicenseValidator$.checkLicense(LicenseValidator.scala:44)
at com.johnsnowlabs.license.LicenseValidator$.isValidLicense$lzycompute(LicenseValidator.scala:23)
at com.johnsnowlabs.license.LicenseValidator$.isValidLicense(LicenseValidator.scala:23)
at com.johnsnowlabs.license.Licensed$class.$init$(Licensed.scala:4)
at com.johnsnowlabs.ocr.transformers.PdfToImage.(PdfToImage.scala:39)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:247)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
at py4j.Gateway.invoke(Gateway.java:238)
at py4j.commands.ConstructorCommand.invokeConstructor(ConstructorCommand.java:80)
at py4j.commands.ConstructorCommand.execute(ConstructorCommand.java:69)
at py4j.GatewayConnection.run(GatewayConnection.java:238)
at java.lang.Thread.run(Thread.java:748)
During handling of the above exception, another exception occurred:
IllegalArgumentException Traceback (most recent call last)
in ()
----> 1 result = pipeline().transform(pdf_example_df)#.cache()
in pipeline()
2
3 # Transforrm PDF document to images per page
----> 4 pdf_to_image = PdfToImage() .setInputCol("content") .setOutputCol("image")
5
6 # Run OCR
/usr/local/lib/python3.7/dist-packages/pyspark/init.py in wrapper(self, *args, **kwargs)
108 raise TypeError("Method %s forces keyword arguments." % func.name)
109 self._input_kwargs = kwargs
--> 110 return func(self, **kwargs)
111 return wrapper
112
/root/.local/lib/python3.7/site-packages/sparkocr/transformers/pdf/pdf_to_image.py in init(self)
69 """
70 super(PdfToImage, self).init()
---> 71 self._java_obj = self._new_java_obj("com.johnsnowlabs.ocr.transformers.PdfToImage", self.uid)
72 self._setDefault(outputCol='image')
73
/usr/local/lib/python3.7/dist-packages/pyspark/ml/wrapper.py in _new_java_obj(java_class, *args)
65 java_obj = getattr(java_obj, name)
66 java_args = [_py2java(sc, arg) for arg in args]
---> 67 return java_obj(*java_args)
68
69 @staticmethod
/usr/local/lib/python3.7/dist-packages/py4j/java_gateway.py in call(self, *args)
1523 answer = self._gateway_client.send_command(command)
1524 return_value = get_return_value(
-> 1525 answer, self._gateway_client, None, self._fqn)
1526
1527 for temp_arg in temp_args:
/usr/local/lib/python3.7/dist-packages/pyspark/sql/utils.py in deco(*a, **kw)
77 raise QueryExecutionException(s.split(': ', 1)[1], stackTrace)
78 if s.startswith('java.lang.IllegalArgumentException: '):
---> 79 raise IllegalArgumentException(s.split(': ', 1)[1], stackTrace)
80 raise
81 return deco
IllegalArgumentException: 'requirement failed: License Key not set please set environment variable JSL_OCR_LICENSE or property jsl.sparkocr.settings.license!'
Your Environment
- Spark-NLP version: 2.7.4
- Apache Spark version: 2.4.4
- Operating System and version: Colab
- Deployment (Docker, Jupyter, Scala, pip, conda, etc.):
We tried this with the key provided and no issue observed at all.. replied in Linkedin.
I've sorted it out after exactly following this instruction.
!!! ATTENTION : After you run this cell, you need to RESTART the COLAB RUNTIME and RE-RUN the cells above and this cell AGAIN due to Colab predefined settings
Thanks @vkocaman for your help.
Hii @vkocaman
I am still facing the same issue. I am working on a healthcare part and using notebook https://colab.research.google.com/github/JohnSnowLabs/spark-nlp-workshop/blob/master/tutorials/streamlit_notebooks/healthcare/NER_DIAG_PROC.ipynb.
Error : ---------------------------------------------------------------------------
IllegalArgumentException Traceback (most recent call last)
in
10 import sparknlp_jsl
11
---> 12 spark = sparknlp_jsl.start(license_keys['SECRET'])
13
14 # manually start session
2 frames
/usr/local/lib/python3.7/dist-packages/pyspark/sql/utils.py in deco(*a, **kw)
115 # Hide where the exception came from that shows a non-Pythonic
116 # JVM exception message.
--> 117 raise converted from None
118 else:
119 raise
IllegalArgumentException: requirement failed: License Key not set please set environment variable JSL_NLP_LICENSE,SPARK_NLP_LICENSE,SPARK_OCR_LICENSE,JSL_OCR_LICENSE,JSL_LICENSE or property jsl.settings.license!
@Siddhijain16 can you check the keys in your keys json that you are given ? do you see SPARK_OCR_LICENSE
or JSL_OCR_LICENSE
?
@Siddhijain16 can you check the keys in your keys json that you are given ? do you see
SPARK_OCR_LICENSE
orJSL_OCR_LICENSE
?
Yes there is SPARK_OCR_LICENSE .
i am facing same issue as in above screenshot , except in my license file i see only SPARK_NLP_LICENSE and not SPARK_OCR_LICENSE or JSL_OCR_LICENSE . Is that a problem or am i missing something. Please help as am stuck with this from long time.