Pyspark Add Redis module _spark

Source: Internet
Author: User
Tags zip folder pyspark install redis

Installing the Redis module
and pack the Redis module

Pip install Redis
mkdir redis
mv .../site-packages/redis redis import shutil dir_name
= "Redis"
output_filename = "./redis"
shutil.make_archive (output_filename, ' zip ', dir_name)

Redis.zip folder structure, must have Redis folder as root folder

redis/
redis/lock.pyc
redis/connection.py
redis/exceptions.py
redis/utils.pyc
redis/_ Compat.pyc
redis/_compat.py
redis/connection.pyc
redis/__init__.py
redis/client.py
redis/utils.py
redis/client.pyc
redis/sentinel.py
redis/sentinel.pyc
redis/lock.py
REDIS/__INIT__.PYC
REDIS/EXCEPTIONS.PYC

Here's the wrong

Lock.pyc
connection.py
exceptions.py
utils.pyc
_compat.pyc
_compat.py Connection.pyc
__init__.py
client.py
utils.py
client.pyc
sentinel.py Sentinel.pyc
lock.py
__init__.pyc
exceptions.pyc
Spark.sparkContext.addPyFile ("Redis.zip")
import Redis

This way, the Redis module is loaded into spark nodes.

Or

./bin/spark-submit--py-files Wesam.zip mycode.py
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.