简体   繁体   English

NameError:未定义名称“ redis”-PySpark-Redis

[英]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.pyconnection.pyexceptions.pylock.pyutils.py等)。

Python version is - 3.5 and spark is 2.7 Python版本是-3.5,spark是2.7

如果将py文件打包为zip并使用sc.addPyFile添加,则应使用import clientimport connector等导入模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM