# Databricks notebook source throws FileNotFoundError: [Errno 2] No such file with PyCharm plugin

aleknandrius
Databricks Partner

I started using Databricks plugin in Pycharm.
If I have first line in my code:

# Databricks notebook source
...

Running such a notebook with a plugin on cluster fails with the message:

FileNotFoundError: [Errno 2] No such file or directory: '/Workspace/Users/<user>/.ide/databricks-Python-e6507fa0/project_name/deployment/model_deployment/notebooks/Test.py'

I checked the directory, the file exists.
Removing:

# Databricks notebook source

Test.py runs as expected.
Any help would be appreciated.

Brahmareddy
Esteemed Contributor II

Hi @aleknandrius,

How are you doing today?

As per my understanding, It seems that the # Databricks notebook source line is causing confusion when running your PyCharm code on Databricks. This line is usually added to identify notebook cells, but in a Python file, it might be misinterpreted by the environment. Consider removing the # Databricks notebook source line when running Python scripts through PyCharm on a cluster, as it’s only necessary when running inside a Databricks notebook. Another option is to ensure that the file is treated purely as a script rather than a notebook when running it in this environment. You might also want to double-check the Databricks plugin configuration in PyCharm to ensure it is set up correctly for running standalone Python scripts.

Please give  a try and let me know for any queries.

Regards,

Brahma