0

我按照网站上的教程,选择“示例笔记本”--深度学习图像分类,(看这里),当我运行时 ml = MLContext(sc),出现如下错误:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/.local/lib/python3.5/site-packages/systemml/classloader.py in createJavaObject(sc, obj_type)
     86     try:
---> 87         return _createJavaObject(sc, obj_type)
     88     except (py4j.protocol.Py4JError, TypeError):

~/.local/lib/python3.5/site-packages/systemml/classloader.py in _createJavaObject(sc, obj_type)
     46     if obj_type == 'mlcontext':
---> 47         return sc._jvm.org.apache.sysml.api.mlcontext.MLContext(sc._jsc)
     48     elif obj_type == 'dummy':

TypeError: 'JavaPackage' object is not callable

During handling of the above exception, another exception occurred:

Py4JJavaError                             Traceback (most recent call last)
<ipython-input-5-724894051c3e> in <module>()
----> 1 ml = MLContext(sc)

~/.local/lib/python3.5/site-packages/systemml/mlcontext.py in __init__(self, sc)
    697             raise ValueError("Expected sc to be a SparkContext or SparkSession, got " % str(type(sc)))
    698         self._sc = sc
--> 699         self._ml = createJavaObject(sc, 'mlcontext')
    700 
    701     def __repr__(self):

~/.local/lib/python3.5/site-packages/systemml/classloader.py in createJavaObject(sc, obj_type)
     92         # First load SystemML
     93         jar_file_name = _getJarFileName(sc, '')
---> 94         x = _getLoaderInstance(sc, jar_file_name, 'org.apache.sysml.utils.SystemMLLoaderUtils', hint + 'SystemML.jar')
     95         x.loadSystemML(jar_file_name)
     96         try:

~/.local/lib/python3.5/site-packages/systemml/classloader.py in _getLoaderInstance(sc, jar_file_name, className, hint)
     69         jar_file_url_arr[0] = jar_file_url
     70         url_class_loader = sc._jvm.java.net.URLClassLoader(jar_file_url_arr, sc._jsc.getClass().getClassLoader())
---> 71         c1 = sc._jvm.java.lang.Class.forName(className, True, url_class_loader)
     72         return c1.newInstance()
     73     else:

/usr/local/lib/python3.5/dist-packages/py4j/java_gateway.py in __call__(self, *args)
   1158         answer = self.gateway_client.send_command(command)
   1159         return_value = get_return_value(
-> 1160             answer, self.gateway_client, self.target_id, self.name)
   1161 
   1162         for temp_arg in temp_args:

~/software/spark-2.1.0-bin-hadoop2.7/python/pyspark/sql/utils.py in deco(*a, **kw)
     61     def deco(*a, **kw):
     62         try:
---> 63             return f(*a, **kw)
     64         except py4j.protocol.Py4JJavaError as e:
     65             s = e.java_exception.toString()

/usr/local/lib/python3.5/dist-packages/py4j/protocol.py in get_return_value(answer, gateway_client, target_id, name)
    318                 raise Py4JJavaError(
    319                     "An error occurred while calling {0}{1}{2}.\n".
--> 320                     format(target_id, ".", name), value)
    321             else:
    322                 raise Py4JError(

Py4JJavaError: An error occurred while calling z:java.lang.Class.forName.
: java.lang.ClassNotFoundException: org.apache.sysml.utils.SystemMLLoaderUtils
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
    at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
    at py4j.Gateway.invoke(Gateway.java:280)
    at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
    at py4j.commands.CallCommand.execute(CallCommand.java:79)
    at py4j.GatewayConnection.run(GatewayConnection.java:214)
    at java.lang.Thread.run(Thread.java:748)

似乎找不到SystemML.jar?我下载的systemml二进制文件可能包含这个文件。但我不知道我能做什么。谢谢!谢谢!!!

4

1 回答 1

2

正如您正确指出的那样,发生错误是因为找不到 SystemML 类。有两种方法可以解决这个问题:

  1. (推荐)我建议不要下载 python 文件,而是通过 pip 安装 SystemML pip install systemml:(发布版本)或pip install https://sparktc.ibmcloud.com/repo/latest/systemml-1.0.0-SNAPSHOT-python.tar.gz(最新代码)。这负责包装必要的罐子。

  2. 如果您更喜欢使用下载的 python 文件,则必须通过pyspark 选项提供SystemML.jarsystemml-*---driver-class-path extra.jar。

于 2017-12-03T05:24:05.307 回答