運行spark時提示 env: ‘python’: No such file or directory


運行spark時提示如下信息:

hadoop@MS-YFYCEFQFDMXS:/home/trp$ cd /usr/local/spark
hadoop@MS-YFYCEFQFDMXS:/usr/local/spark$ ./bin/pyspark
env: ‘python’: No such file or directory

 

原因:沒有配置Spark python的環境變量

 

解決步驟:

1、添加python相關環境變量

hadoop@MS-YFYCEFQFDMXS:/usr/local/spark$ nano ~/.bashrc

 在末尾插入:注: py4j-0.10.9-src.zip  在目錄下 \usr\local\spark\python\lib

export PYTHONPATH=$SPARK_HOME/python:$SPARK_HOME/python/lib/py4j-0.10.9-src.zip:$PYTHONPATH
export PYSPARK_PYTHON=python3

修改后使用 Ctrl+X,
提示:save modified buffer ...?    ,選擇 :yes
又提示:file name to write :***.launch   ,選擇:Ctrl+T
在下一個界面用 “上下左右” 按鍵 選擇要保存的文件名,
然后直接點擊 “Enter” 按鍵即可保存。

 

2、讓環境變量生效

hadoop@MS-YFYCEFQFDMXS:/usr/local/spark$ source ~/.bashrc

 

3、運行pyspark

hadoop@MS-YFYCEFQFDMXS:/usr/local/spark$ ./bin/pyspark
Python 3.8.2 (default, Mar 13 2020, 10:14:16)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
2020-07-19 21:35:40,464 WARN util.Utils: Your hostname, MS-YFYCEFQFDMXS resolves to a loopback address: 127.0.1.1; using 192.168.13.139 instead (on interface wifi0)
2020-07-19 21:35:40,466 WARN util.Utils: Set SPARK_LOCAL_IP if you need to bind to another address
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.spark.unsafe.Platform (file:/usr/local/spark/jars/spark-unsafe_2.12-3.0.0.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Please consider reporting this to the maintainers of org.apache.spark.unsafe.Platform
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2020-07-19 21:35:41,865 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
Welcome to
      ____              __
     / __/__  ___ _____/ /__
    _\ \/ _ \/ _ `/ __/  '_/
   /__ / .__/\_,_/_/ /_/\_\   version 3.0.0
      /_/

Using Python version 3.8.2 (default, Mar 13 2020 10:14:16)
SparkSession available as 'spark'.
>>>

 

 

查看Web監控頁面

http://localhost:4040/jobs/

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM