08-07-2025 03:28 AM
Hi,
I'm testing out running one Notebook from another using the %run magic command in the Databricks Free Edition. Just really simple test stuff but get the following error:
Failed to parse %run command: string matching regex '\$[\w_]+' expected but 'p' found. If notebook path contains spaces, wrap with double quotes.
The path doesn't contain spaces and wrapping in double quotes doesn't help, either.
Any suggestions?
08-07-2025 06:42 AM
@JonnyData, it's considered best practice to put %run in a cell by itself. If you include other code (like print(book_publisher)) in the same cell, it may execute before the %run command has finished loading everything.
You can try either of the following approaches:
https://docs.databricks.com/aws/en/notebooks/notebook-workflows#use-run-to-import-a-notebook
08-07-2025 04:32 AM
Hello @JonnyData!
This parsing error typically appears when the notebook path isn't in the expected format. Could you share the exact %run command you're using?
Also, please ensure the path is a workspace path, either absolute (starting with /) or relative (like ./NotebookName, and both notebooks must be in the same folder).
08-07-2025 04:51 AM
Hi Advika - thanks for this.
In my Workspace I've first created a folder called HolusTest
In there I have 2 Notebooks HolusTest1 which containes the lines:
and HolusTestSetup, which contains one line
The language 'default' for both is python and the code's from Databricks Certified Data Engineer Associate Study Guide which I'm just working through to give myself a better all round grounding in Databricks.
Thanks in advance for any help
08-07-2025 06:42 AM
@JonnyData, it's considered best practice to put %run in a cell by itself. If you include other code (like print(book_publisher)) in the same cell, it may execute before the %run command has finished loading everything.
You can try either of the following approaches:
https://docs.databricks.com/aws/en/notebooks/notebook-workflows#use-run-to-import-a-notebook
08-07-2025 08:12 AM
Hi Advika,
Thanks for that - it worked a treat!
Cheers
John
Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!
Sign Up Now