'JavaPackage' object is not callable for Cognitive Services
TypeError: 'JavaPackage' object is not callable Traceback (most recent call last):
File "/opt/spark/python/lib/pyspark.zip/pyspark/init.py", line 114, in wrapper return func(self, **kwargs)
File "/home/trusted-service-user/cluster-env/env/lib/python3.8/site-packages/synapse/ml/cognitive/EntityDetector.py", line 95, in init self._java_obj = self._new_java_obj("com.microsoft.azure.synapse.ml.cognitive.EntityDetector", self.uid)
File "/opt/spark/python/lib/pyspark.zip/pyspark/ml/wrapper.py", line 66, in _new_java_obj return java_obj(*java_args)
TypeError: 'JavaPackage' object is not callable
Seems like Issue #1296 is a similar issue. I've checked my Spark, Scala, and Python versions are as required. Wondering if there is any suggestions to this issue? Thanks!
AB#1984484
hey @Jess0-0 thanks for raising this issue, could you share a repro so we can check this out on our side? Thanks
I also got the same error while downloading synapse. I am on Ubuntu 20.04 (WSL2) I installed Spark using pip and it's working fine. I also installed synapse with pip successfully.
No execution error with these imports:
import pyspark sc = pyspark.sql.SparkSession.builder.appName("MyApp") \ .config("spark.jars.packages", "com.microsoft.azure:synapseml_2.12:0.9.5") \ .config("spark.jars.repositories", "https://mmlspark.azureedge.net/maven") \ .getOrCreate()
import synapse.ml
But I got execution error with this: `from synapse.ml.isolationforest import *
isolationForest = (IsolationForest() .setNumEstimators(100) .setBootstrap(False) .setMaxSamples(256) .setMaxFeatures(1.0) .setFeaturesCol("features") .setPredictionCol("predictedLabel") .setScoreCol("outlierScore") .setContamination(0.02) .setContaminationError(0.02 * 0.01) .setRandomSeed(1))`
Here is the error: `File /mnt/c/Users/PATH/ubuntu_smu_venv/lib/python3.8/site-packages/synapse/ml/isolationforest/IsolationForest.py:77, in IsolationForest.init(self, java_obj, bootstrap, contamination, contaminationError, featuresCol, maxFeatures, maxSamples, numEstimators, predictionCol, randomSeed, scoreCol) 75 super(IsolationForest, self).init() 76 if java_obj is None: ---> 77 self._java_obj = self._new_java_obj("com.microsoft.azure.synapse.ml.isolationforest.IsolationForest", self.uid) 78 else: 79 self._java_obj = java_obj
File /mnt/c/PATH/ubuntu_smu_venv/lib/python3.8/site-packages/pyspark/ml/wrapper.py:66, in JavaWrapper._new_java_obj(java_class, *args) 64 java_obj = getattr(java_obj, name) 65 java_args = [_py2java(sc, arg) for arg in args] ---> 66 return java_obj(*java_args)
TypeError: 'JavaPackage' object is not callable `
I cant repro this so it is probably an install issue.
Are you running locally or on a cluster provider like Synapse. If the latter than the spark session builder wont add the package and you should install via the synapse-specific install instructions at the bottom of our homepage:
https://microsoft.github.io/SynapseML/
Please comment to reopen
milton723 : your comment was very helpful