pyspark AttributeError: 'NoneType' object has no attribute 'setCallSite'
pyspark:
AttributeError: 'NoneType' object has no attribute 'setCallSite'
我草,是pyspark的bug。解决方法:
print("Approximately joining on distance smaller than 0.6:")
distance_min = model.approxSimilarityJoin(imsi_proc_df, imsi_proc_df, 1e6, distCol="JaccardDistance") \
.select(col("datasetA.id").alias("idA"),
col("datasetB.id").alias("idB"),
col("JaccardDistance")) #.filter("idA=idB")
print(distance_min.show())
print("*"*88)
print(imsi_proc_df.show()) key = Vectors.sparse(53, [1, 3], [1.0, 1.0])
print(model.approxNearestNeighbors(imsi_proc_df, key, 2).show())
print("start calculate find botnet!")
print("*"*99)
print("time start:", time.time())
print(type(distance_min), dir(distance_min))
print(dir(distance_min.toLocalIterator)) ############################################## add this line to solve
distance_min.sql_ctx.sparkSession._jsparkSession = spark_app._jsparkSession
distance_min._sc = spark_app._sc
############################################# similarity_val_rdd = distance_min.toLocalIterator #.collect()
print("time end:", time.time())
print(similarity_val_rdd)
print("*"*99)
try:
G = ConnectedGraph()
ddos_ue_list = []
for item in similarity_val_rdd():
imsi, imsi2, jacard_similarity_val = item["idA"], item["idB"], item["JaccardDistance"]
print("???", imsi, imsi2, jacard_similarity_val)
Description
reproducing the bug from the example in the documentation:
import pyspark
from pyspark.ml.linalg import Vectors
from pyspark.ml.stat import Correlation
spark = pyspark.sql.SparkSession.builder.getOrCreate()
dataset = [[Vectors.dense([1, 0, 0, -2])],
[Vectors.dense([4, 5, 0, 3])],
[Vectors.dense([6, 7, 0, 8])],
[Vectors.dense([9, 0, 0, 1])]]
dataset = spark.createDataFrame(dataset, ['features'])
df = Correlation.corr(dataset, 'features', 'pearson')
df.collect()
This produces the following stack trace:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-92-e7889fa5d198> in <module>()
11 dataset = spark.createDataFrame(dataset, ['features'])
12 df = Correlation.corr(dataset, 'features', 'pearson')
---> 13 df.collect() /opt/spark/python/pyspark/sql/dataframe.py in collect(self)
530 [Row(age=2, name=u'Alice'), Row(age=5, name=u'Bob')]
531 """
--> 532 with SCCallSiteSync(self._sc) as css:
533 sock_info = self._jdf.collectToPython()
534 return list(_load_from_socket(sock_info, BatchedSerializer(PickleSerializer()))) /opt/spark/python/pyspark/traceback_utils.py in __enter__(self)
70 def __enter__(self):
71 if SCCallSiteSync._spark_stack_depth == 0:
---> 72 self._context._jsc.setCallSite(self._call_site)
73 SCCallSiteSync._spark_stack_depth += 1
74 AttributeError: 'NoneType' object has no attribute 'setCallSite'
Analysis:
Somehow the dataframe properties `df.sql_ctx.sparkSession._jsparkSession`, and `spark._jsparkSession` do not match with the ones available in the spark session.
The following code fixes the problem (I hope this helps you narrowing down the root cause)
df.sql_ctx.sparkSession._jsparkSession = spark._jsparkSession
df._sc = spark._sc df.collect() >>> [Row(pearson(features)=DenseMatrix(4, 4, [1.0, 0.0556, nan, 0.4005, 0.0556, 1.0, nan, 0.9136, nan, nan, 1.0, nan, 0.4005, 0.9136, nan, 1.0], False))]
pyspark AttributeError: 'NoneType' object has no attribute 'setCallSite'的更多相关文章
- python3 AttributeError: 'NoneType' object has no attribute 'split'
from wsgiref.simple_server import make_server def RunServer(environ, start_response): start_response ...
- AttributeError: 'NoneType' object has no attribute 'split' 报错处理
报错场景 social_django 组件对原生 django 的支持较好, 但是因为 在此DRF进行的验证为 JWT 方式 和 django 的验证存在区别, 因此需要进行更改自行支持 JWT 方式 ...
- python提示AttributeError: 'NoneType' object has no attribute 'append'【转发】
在写python脚本时遇到AttributeError: 'NoneType' object has no attribute 'append' a=[] b=[1,2,3,4] a = a.appe ...
- python提示AttributeError: 'NoneType' object has no attribute 'append'
在写python脚本时遇到AttributeError: 'NoneType' object has no attribute 'append' a=[] b=[1,2,3,4] a = a.appe ...
- Keras AttributeError 'NoneType' object has no attribute '_inbound_nodes'
问题说明: 首先呢,报这个错误的代码是这行代码: model = Model(inputs=input, outputs=output) 报错: AttributeError 'NoneType' o ...
- AttributeError: 'NoneType' object has no attribute 'extend'
Python使用中可能遇到的小问题 AttributeError: 'NoneType' object has no attribute 'extend' 或者AttributeError: 'Non ...
- 解决opencv:AttributeError: 'NoneType' object has no attribute 'copy'
情况一: 路径中有中文,更改即可 情况二:可以运行代码,在运行结束时显示 AttributeError: 'NoneType' object has no attribute 'copy' 因为如果是 ...
- appium 报错:AttributeError:"NoneType' object has no attribute 'XXX'
报错截图如下: 问题原因: 根据以上报错提示可已看到问题的原因为:logger中没有info此方法的调用,点击"具体报错的位置"上面的链接,可直接定位到具体的报错位置.根据分析所得 ...
- PIL中分离通道发生“AttributeError: 'NoneType' object has no attribute 'bands'”
解决方法: 这个貌似是属于一个bug 把Image.py中的1500行左右的split函数改成如下即可: def split(self): "Split image into bands&q ...
随机推荐
- 切换普通用户报 -bash: fork: retry: No child processes
ssh 连接普通用户 报这个错误 -bash: fork: retry: No child processes 解决办法: 更改vi /etc/security/limits.d/20-nproc.c ...
- 第4/7Beta冲刺
1.团队成员 成员姓名 成员学号 秦裕航 201731062432(组长) 刘东 201731062227 张旭 201731062129 王伟 201731062214 2.SCRU部分 2.1各成 ...
- 「LOJ2091」「ZJOI2016」小星星 容斥+DP
题目描述 小 Y 是一个心灵手巧的女孩子,她喜欢手工制作一些小饰品.她有\(n\)颗小星星,用 \(m\)条彩色的细线串了起来,每条细线连着两颗小星星.有一天她发现,她的饰品被破坏了,很多细线都被拆掉 ...
- Linux 反弹 Shell
攻击场景 Attacker:192.168.0.106 win10 Victim:192.168.2.140 kali NC 反弹 shell Netcat简介 俗称瑞士军刀或NC,小巧强悍,可以读写 ...
- linux 下用C实现 ATM 自动取款机功能 (进程间通信)
直接先上图: 项目需求: 主要分为两人大模块: 客户端 .进入时的功能开户.销户.登录.解锁 开户:输入姓名.身份证号.设置密码,如果开户成功,则服务器上保存一个账号信号(一个账号存一个文件,文件名建 ...
- python模块之openpyxl
这是一个第三方库,可以处理xlsx格式的Excel文件.pip install openpyxl安装.如果使用Aanconda,应该自带了. 读取Excel文件 需要导入相关函数. from open ...
- Java多线程编程之读写锁【ReentrantReadWriteLock】
有时候我们需要有这样的需求: 对于同一个文件进行读和写操作,普通的锁是互斥的,这样读的时候会加锁,只能单线程的读,我们希望多线程的进行读操作,并且读的时候不能进行写操作,写的时候不能进行 ...
- Disruptor底层源码解析(九)
架构图: 性能为什么这么牛逼: public void sendData(ByteBuffer data) { //1 在生产者发送消息的时候, 首先 需要从我们的ringBuffer里面 获取一个可 ...
- Oracle 11g安装过程工作Oracle数据库安装图解
一.Oracle 下载 注意Oracle分成两个文件,下载完后,将两个文件解压到同一目录下即可. 路径名称中,最好不要出现中文,也不要出现空格等不规则字符. 官方下地址: oracle.com/tec ...
- C盘清理、C盘瘦身、省出30G
三招C盘瘦身30G,清理win10系统中虚占C盘空间的三大祸害 1.对C盘进行“磁盘清理” C盘右键->属性->磁盘清理->清理系统文件->勾选“windows更新清理”-&g ...