Forum Discussion
AI functions with PySpark error
- 8 months ago
v-karpurapud sooooo. I turned out to be the issue was sitting infront of the screen not in the screen đ
I was only importing the libary for pandas and was not award that the pyspark library is a different one. So for all ready this post, the solution is to import the correct relevant library.
import synapse.ml.aifunc as aifunc --> for Pandasimport synapse.ml.spark.aifunc as aifunc --> for PySparkNevertheless, thanks for the support here in this thread!v-karpurapud may I can take my own answer as solution?
Hi Mauro89
Thank you for contacting the Microsoft Fabric community forum.
The setting shown in your screenshot enables Copilot/OpenAI features for the whole tenant, but it doesn't ensure that the Spark AI extension is active in your notebook session. The .ai accessor comes from the Spark AI integration, which relies on the AI Spark Extensions being enabled on the specific capacity where your workspace is running.
Even with Runtime 1.3, the extension might not load if the environment kernel starts without the AI Spark package or if the capacity-level AI features for âAI in notebooks / Spark AI Extensionsâ are not enabled.To check this, you can run the following in your notebook:
hasattr(spark.createDataFrame([("x",)], ["col"]), "ai")
If this returns False, the Spark AI extension did not load. If your capacity settings are correct but it still doesnât load, it could be a deployment issue in that case, you should contact Fabric support, since .ai should be available on Runtime 1.3.
As a workaround, you can use the helper class:
from fabricext.ai import AISpark
I hope this information is helpful. If you have any further questions, please let us know. we can assist you further.
Regards,
Microsoft Fabric Community Support Team.
Hi v-karpurapud,
Iam still not sure to which extension you relate (AI Spark Extensions being enabled on the specific capacity)?
Is it in the admin portal or where can I find it? As Iam Admin in the Fabric environment as well as capacity I assume I can enable it once found.
And the workaround throughs the follwoing error:
No module named 'fabricext'
Thanks and best regards!
- v-karpurapud8 months agoCommunity Support
Hi Mauro89
To clarify, when I mentioned âAI Spark Extensions being enabled on the capacity,â I did not mean there is a manual setting in the Admin Portal, as such an option does not exist. The Spark AI layer is included, but Microsoft activates it automatically during the Fabric Runtime rollout, and its availability may differ based on capacity or region.
In this context, âenabledâ signifies that the Spark AI components are present in the capacityâs runtime and accessible to notebooks. In your case, the absence of both df.ai and the fabricext module suggests that the Spark AI package is not yet available on your capacity, despite being on Runtime 1.3 with tenant-level Copilot/OpenAI enabled.
Since this extension is generally expected to be available, we recommend submitting a support ticket so the Fabric team can review your capacity and assist further.
You can submit a ticket via the Microsoft Power BI Support Portal:
How to create a Fabric and Power BI Support ticket - Power BI | Microsoft Learn
Regards,
Microsoft Fabric Community Support Team.
- Mauro898 months agoSuper User
Thanks v-karpurapud for clarification.
I have created a ticket and will keep this thread posted about the solution.
- v-karpurapud8 months agoCommunity Support
Hi Mauro89
Thanks for the update. Hope your issue gets resolved soon. when it does, please share the insights with the community as it can be helpful to others.