[英]NameError: name 'redis' is not defined - PySpark - Redis
I am using the addPyFile
method in pyspark to load the redis.zip
file. 我在
addPyFile
中使用addPyFile
方法加载redis.zip
文件。 I am able to load the file using 我可以使用加载文件
sc.addPyFile("/home/path/to/redis.zip")
But while running the code using ./pyspark
, it is showing the error: 但是在使用
./pyspark
运行代码时,它显示了错误:
NameError: name 'redis' is not defined
NameError:名称“ redis”未定义
The zip( redis.zip
) contains .py
files( client.py
, connection.py
, exceptions.py
, lock.py
, utils.py
and others). zip(
redis.zip
)包含.py
文件( client.py
, connection.py
, exceptions.py
, lock.py
, utils.py
等)。
Python version is - 3.5 and spark is 2.7 Python版本是-3.5,spark是2.7
如果将py文件打包为zip并使用sc.addPyFile
添加,则应使用import client
, import connector
等导入模块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.