Python 使用subprocess.Popen的hadoop distcp

Python 使用subprocess.Popen的hadoop distcp,python,python-2.7,hadoop,hdfs,Python,Python 2.7,Hadoop,Hdfs,我试图在python中使用subprocess.Popen运行hadoop distcp命令,并获取错误-无效输入。如果我以Hadoop命令的形式运行,那么同样的命令也可以正常运行 Hadoop命令: hadoop distcp -log /user/name/distcp_log -skipcrccheck -update hdfs://xxxxx:8020/sourceDir hdfs://xxxxx:8020/destDir 在python中: from subprocess impor

我试图在python中使用subprocess.Popen运行hadoop distcp命令,并获取错误-无效输入。如果我以Hadoop命令的形式运行,那么同样的命令也可以正常运行

Hadoop命令:

hadoop distcp -log /user/name/distcp_log -skipcrccheck -update hdfs://xxxxx:8020/sourceDir hdfs://xxxxx:8020/destDir
在python中:

from subprocess import Popen, PIPE
proc1 = Popen(['hadoop','distcp','-log /user/name/distcp_log -skipcrccheck -update', 'hdfs://xxxxx:8020/sourceDir', 'hdfs://xxxxx:8020/destDir'], stdout=subprocess.PIPE)
日志消息:

INFO tools.OptionsParser: parseChunkSize: blocksperchunk false
INFO tools.DistCp: Input Options: DistCpOptions{atomicCommit=false, syncFolder=false, deleteMissing=false, ignoreFailures=false, overwrite=false, append=false, useDiff=false, useRdiff=false, fromSnapshot=null, toSnapshot=null, skipCRC=false, blocking=true, numListstatusThreads=0, maxMaps=20, mapBandwidth=100, sslConfigurationFile='null', copyStrategy='uniformsize', preserveStatus=[], preserveRawXattrs=false, atomicWorkPath=null, logPath=null, sourceFileListing=null, sourcePaths=[-log /user/name/distcp_log -skipcrccheck -update, hdfs://xxxxx:8020/sourceDir], targetPath=hdfs://xxxxx:8020/destDir, targetPathExists=true, filtersFile='null', blocksPerChunk=0, copyBufferSize=8192}
ERROR tools.DistCp: Invalid input:
org.apache.hadoop.tools.CopyListing$InvalidInputException: -log /user/name/distcp_log -skipcrccheck -update doesn't exist
它将选项视为源目录。 如何告诉子流程这些是选项,不应被视为源(sourcepath=[-log/user/name/distcp\u log-skipcrccheck-update,hdfs://xxxxx:8020/sourceDir])

我使用的是Python2.7,无法访问pip安装及其Kerberos群集。 希望为集群内传输运行此命令,但在此之前,希望在集群内尝试此简单命令


谢谢

将命令行的所有参数拆分为Popen first参数列表的单独元素:

from subprocess import Popen, PIPE
proc1 = Popen(['hadoop','distcp','-log', '/user/name/distcp_log', '-skipcrccheck', '-update', 'hdfs://xxxxx:8020/sourceDir', 'hdfs://xxxxx:8020/destDir'], stdout=subprocess.PIPE)
您可以找到
Popen
文档,其中说明
args
应该是通过将所有参数按
'
拆分而创建的列表