file transfer through CLI to DBFS, working manually but not in python code...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2023 02:24 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 07:41 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 07:56 PM
The 127 error code indicates “command not found”,
Try using the full path of the databricks command

