cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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 III

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
Databricks Employee
Databricks Employee

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
Honored Contributor

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

Try using the full path of the databricks command

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group