Home > database >  FileNotFoundError: [Errno 2] No such file or directory when put file in hdfs
FileNotFoundError: [Errno 2] No such file or directory when put file in hdfs

Time:05-16

I use subprocess.popen in python to put files in hdfs. it runs accurately using python on the Windows cmd. but as I use vscode to run the code, I get "FileNotFoundError: [Errno 2] No such file or directory: Error.

hdfs_path = os.path.join(os.sep,'mongo_import_export')

#put csv into hdfs 

put = Popen(['hadoop','dfs','-put','mongo-hadoop/import_export.csv','/mongo_import_export'], stdin=PIPE,bufsize=-1)

put.communicate()

Knowing that my file import_export.csv is in the file in witch the code is located and mong-hadoop folder is in my local files

CodePudding user response:

VSCode is running the code in a different working directory than your local CMD. Use the absolute path to the files you want to put rather than relative paths.

  • Related