Forum Discussion

KJ14's avatar
KJ14
New Member
2 days ago

Unexpected error in fabric pyspark notebook

Hi Everyone, 

I am using Fabric pyspark notebook .It was as working fine until last month but when i am trying to run it now but showing error like F is not defined but I have already imported functions as F one time it runs successfully next time it gives error even if function or variable is already defined .Can anyone help me.

3 Replies

  • Hi KJ14​,

    Can you post the full error message, and the structure of the notebook? 

    Are you using multiple cells? Are the imports in one cell but not another? 

    Are you running cells individually or all at once? Are you stopping and starting sessions mid way through running cells? 

    When a session stops, all context is lost, so previously run cells no longer have their outputs, or their imported functions. 

     

  • Kagiyama_yutaka's avatar
    Kagiyama_yutaka
    Continued Contributor

    If you don’t mind, can you share your cell layout and the full error text? Even a short snippet is fine. Without that, it’s basically guesswork and I can’t say why F is suddenly undefined.

    Fabric notebooks sometimes drop state between runs, so imports or variables just disappear. I need to see the cell order + exact error to confirm if that’s the case.

  • hey KJ14​ please share the error message and let's see if we can help you.

    My guess (exploring using Copilot), the error "F is not defined" may indicate that the Spark session was restarted and the notebook lost variables/imports that were previously loaded. Making sure the import cell is executed before any cell that uses that "F" could help.