cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

file transfer through CLI to DBFS, working manually but not in python code...

pshuk
New Contributor II

Hi,

I ran my code sucessfully in the past but suddenly it stopped working. I have a python code that transfer local files to DBFS location using CLI. When I run the command manually on the screen, it works but in the code, it gives me the error  "returned non-zero exit status 127". Can anyone help me please... 

Here is the part of the code that was working fine but now it is not..

my_cmd = "databricks fs cp "+row_file+" "+upload_dir

                    run_args = {"shell":True, "check":True, "capture_output":True}

                    subprocess.run(my_cmd, **run_args)

and the my_cmd is this: databricks fs cp /mnt/farm/DNAlab/WGL/Samples/Data\ Analysis/Emedgene/HPO/2302706.HPO.txt dbfs:/FileStore/LiveDataUpload/WES_HPO_Dec16/

 

which runs fine if I copy it and execute it on shell prompt. any idea, what could be going wrong? TIA

2 REPLIES 2

brockb
New Contributor III
New Contributor III

Hi,

I tried replicating your test and it worked for me so I'm not sure what's going on without knowing more about which Runtime, python version, etc you're using. But regardless, perhaps `dbutils.fs.cp` would be an easier way of doing what you're trying to achieve? You could call it directly from a python notebook cell and not have to make `subprocess` calls.

Details here: https://docs.databricks.com/en/dev-tools/databricks-utils.html#cp-command-dbutilsfscp

Thanks.

feiyun0112
Contributor III

The 127 error code indicates โ€œcommand not foundโ€,

Try using the full path of the databricks command

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.