推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
marin1995
V2EX  ›  Python

pyspark 连接 spark 集群部署问题

  •  
  •   marin1995 · Jan 15, 2020 · 4353 views
    This topic created in 2459 days ago, the information mentioned may be changed or developed.
    请教一下各位大佬,我现在使用 pysaprk 做 sparkstreaming 处理 kafka 的数据。程序单机跑的时候没有问题,连接集群的时候就会报错 no module named "xxxx",连接方式是在程序是设置 setMaster(""spark://host:port)。是不是还要配置其他环境变量呢?麻烦大佬指点一下,有偿~
    3 replies  •  2020-01-15 19:01:59 +08:00
    besttime
        1
    besttime  
       Jan 15, 2020   ❤️ 1
    pyspark 的 job 提交到 spark 后,会调用 spark 所在环境的 python 解释器,而这个报错的问题就是在于 spark 所在的环境的 python 解释器缺乏你使用的类库。
    fzy0728
        2
    fzy0728  
       Jan 15, 2020
    xiaoxuxu
        3
    xiaoxuxu  
       Jan 15, 2020   ❤️ 1
    可以用 pyenv 建个 Python 环境,然后打成压缩包。运行 spark-submit 的时候用--archives 传这个压缩包,并且设置 PYSPARK_DRIVER_PYTHON、PYSPARK_PYTHON 为压缩包内 Python 可执行文件的相对路径,大概是这样:

    PYSPARK_PYTHON=./python-env/bin/python PYSPARK_DRIVER_PYTHON=./python-env/bin/python spark-submit --master yarn --deploy-mode cluster --archives python-env.zip#python-env
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5662 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 08:39 · PVG 16:39 · LAX 01:39 · JFK 04:39
    ♥ Do have faith in what you're doing.