PySpark,Tensorflow和Tensorframes-ClassNotFoundException

时间:2018-10-04 20:11:00

标签: tensorflow pyspark

我尝试从sample repository运行一个简约的代码:

import tensorflow as tf
import tensorframes as tfs
from pyspark.sql import Row
from pyspark.sql import SparkSession

spark = SparkSession\
    .builder\
    .appName("example-spark")\
    .master("local[*]")\
    .getOrCreate()

data = [Row(x=float(x)) for x in range(10)]
df = spark.createDataFrame(data)
with tf.Graph().as_default() as g:
    x = tfs.block(df, "x")
    z = tf.add(x, 3, name='z')
    df2 = tfs.map_blocks(z, df)

df2.collect()

不幸的是,我遇到了错误(我认为配置可能有问题)。我尝试了其他选项(主要是设置路径和附加文件),但仍然无法处理。

   Traceback (most recent call last):
  File "spark-ml.py", line 80, in <module>
    x = tfs.block(df, "x")
  File "/home/btw/.local/lib/python3.5/site-packages/tensorframes/core.py", line 413, in block
    return _auto_placeholder(df, col_name, tf_name, block = True)
  File "/home/btw/.local/lib/python3.5/site-packages/tensorframes/core.py", line 431, in _auto_placeholder
    info = _java_api().extra_schema_info(df._jdf)
  File "/home/btw/.local/lib/python3.5/site-packages/tensorframes/core.py", line 34, in _java_api
    return _jvm.Thread.currentThread().getContextClassLoader().loadClass(javaClassName) \
  File "/home/btw/.local/lib/python3.5/site-packages/py4j/java_gateway.py", line 1257, in __call__
    answer, self.gateway_client, self.target_id, self.name)
  File "/home/btw/.local/lib/python3.5/site-packages/pyspark/sql/utils.py", line 63, in deco
    return f(*a, **kw)
  File "/home/btw/.local/lib/python3.5/site-packages/py4j/protocol.py", line 328, in get_return_value
    format(target_id, ".", name), value)
py4j.protocol.Py4JJavaError: An error occurred while calling o55.loadClass.
: java.lang.ClassNotFoundException: org.tensorframes.impl.DebugRowOps
        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 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:282)
        at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
        at py4j.commands.CallCommand.execute(CallCommand.java:79)
        at py4j.GatewayConnection.run(GatewayConnection.java:238)
        at java.lang.Thread.run(Thread.java:748)

0 个答案:

没有答案