我正在努力为我的python路径增加火花:
(myenv)me@me /home/me$ set SPARK_HOME="/home/me/spark-1.2.1-bin-hadoop2.4"
(myenv)me@me /home/me$ set PYTHONPATH=$PYTHONPATH:$SPARK_HOME:$SPARK_HOME/python:$SPARK_HOME/python/build:$SPARK_HOME/bin
(myenv)me@me /home/me$ python -c 'import sys; print(sys.path)'
['', '/home/me/.virtualenvs/default/lib/python2.7', '/home/me/.virtualenvs/default/lib/python2.7/plat-x86_64-linux-gnu', '/home/me/.virtualenvs/default/lib/python2.7/lib-tk', '/home/me/.virtualenvs/default/lib/python2.7/lib-old', '/home/me/.virtualenvs/default/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/home/me/.virtualenvs/default/local/lib/python2.7/site-packages', '/home/me/.virtualenvs/default/lib/python2.7/site-packages']
(myenv)me@me /home/me$ python -c 'import pyspark'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named pyspark
答案 0 :(得分:6)
我遇到了同样的问题,但是this 有帮助。
只需在.bashrc
中添加以下命令即可export SPARK_HOME=/path/to/your/spark-1.4.1-bin-hadoop2.6
export PYTHONPATH=$SPARK_HOME/python:$SPARK_HOME/python/build:$PYTHONPATH
export PYTHONPATH=$SPARK_HOME/python/lib/py4j-0.8.2.1-src.zip:$PYTHONPATH
答案 1 :(得分:0)
我认为你混淆了PYTHONPATH
和sys.path
。但是,如果正确安装了PYTHONPATH
,您确定需要修改pyspark
吗?
编辑:
我还没有使用过pyspark,但这会有帮助吗? importing pyspark in python shell