0

Google Cloud Dataproc 용 Python 클라이언트 라이브러리를 사용하여 클러스터를 자동으로 프로비저닝하고 작업을 제출하는 등의 스크립트를 실행하고 있습니다. 직장이면 ImportError: no module named pandas과 함께 반환됩니다. 나는 판다 (pandas)를 가져오고, 스크립트에서 작업이 실행되는 다른 여러 패키지를 가져옵니다. 이 문제를 해결하는 방법을 모르겠습니다.Dataproc에서 작업 제출을 시도 할 때 "ImportError : 모듈 이름이 pandas"가 아닙니다.

이렇게 의미가 있습니까?

#!/bin/bash 
    list= "python-pandas, python-numpy, python-argparse" 

    ROLE=$(/usr/share/google/get_metadata_value attributes/dataproc-role) 

    if [[ "${ROLE}" == 'Master' ]]; then 
     for i in $list; do 
      sudo apt-get install -y $i 
     done 

     wget -P /home/anaconda2/ https://repo.continuum.io/archive/Anaconda2-4.3.1-Linux-x86_64.sh 
     bash /home/anaconda2/Anaconda2-4.3.1-Linux-x86_64.sh -b -f -p /home/anaconda2/ 
     chmod /home/anaconda2 0777 
     /home/anaconda2/bin/pip install lxml 
     /home/anaconda2/bin/pip install jupyter-spark 
     /home/anaconda2/bin/pip install jgscm 

    fi 
+0

는 그런 것 같아요 [ 'pandas'] (http://pandas.pydata.org/) 모듈을 설치해야합니다. –

답변

1

Pands을 통해 Dataproc에 기본적으로 설치되지 않습니다

#!/bin/bash 
    ROLE=$(/usr/share/google/get_metadata_value attributes/dataproc-role) 
    if [[ "${ROLE}" == 'Master' ]]; then 
     apt-get install python-pandas -y 
     apt-get install python-numpy -y 
     apt-get install g++ cmake 
     apt-get install python-math 
     apt-get install python-argparse 
     apt-get install python-os 
     apt-get install python-sys 
     apt-get install python-glob 
     apt-get install python-gzip 
     apt-get install python-hail 
    fi 

은 여기 내 업데이트 bash는 스크립트입니다. 이 one과 비슷한 초기화 동작을 통해 사용자 정의 Python 라이브러리를 설치할 수 있습니다. 내 초기화 작업을 간단히

#!/usr/bin/python 
import pyspark 
import pandas 
sc = pyspark.SparkContext() 
vals = sc.parallelize(xrange(1, 100)) 
reprs = vals.mapPartitions(lambda es: [repr(pandas) for e in es]) 
for r in reprs.collect(): 
    print r 

입니다

:

이 참고로, 나는 적어도 하나 개의 노드에서 발견되는이 팬더를 확인하기 위해 바로 다음 실행했습니다

#!/bin/bash 
apt-get install python-pandas python-numpy -y 
+0

내 버전의 초기화 작업 스크립트를 위에 추가해야합니다. 그것은 모두 의미가 있습니까? – claudiadast

+0

팬더와 numpy는 확실히 이해가됩니다. 다른 모든 것들이 런타임에 필요하다면 약간 궁금합니다. (g ++을 사용하면 미리 작성된 패키지를 사용하는 것이 좋을 것 같습니다). 자신이하는 일에 따라 마스터가 아닌 모든 노드에이 패키지를 설치하기 만하면됩니다. 마지막으로 apt-get install을 한 번 호출하면 시작 시간이 절약됩니다. –

+0

위의 링크 (팬더를 설치하는 링크)를 제공 한 초기화 스크립트를 사용하면 pyspark 작업을 제출할 때 여전히'no module named pandas' 오류가 발생합니다. – claudiadast