Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
Laila92
Helper V
Helper V

Query contains unknown function name: Python.Execute

I used a Python script in Power Query to pull data from a Google Sheet. It works fine in PBI Desktop, but I get an error for the automated refresh:

You can't schedule refresh for this dataset because the following data sources currently don't support refresh:

Discover Data Sources
Query contains unknown function name: Python.Execute Unknown function name: Python.Execute is a valid Mashup library function name format. Hence fail the operation.

 
This is the Python script that works on desktop but not for sched. refresh (anonimized the spreadsheet key):

import numpy as np
import pandas as pd
pd.options.mode.chained_assignment = None
import re
import gspread
import csv
from oauth2client.service_account import ServiceAccountCredentials
from df2gspread import df2gspread as d2g
import glob
from datetime import datetime
from datetime import date
import calendar
import requests
from dateutil.parser import parse




def connect_to_gsheets():
    scope = ['https://spreadsheets.google.com/feeds','https://www.googleapis.com/auth/drive']
    credentials = ServiceAccountCredentials.from_json_keyfile_name(r'C:\Users\Laila\Documents\Python Scripts\google_spreadsheet_secret_key.json', scope)
    gc = gspread.authorize(credentials)
    return gc,credentials

def read_cost_sheet():
    gc,credentials = connect_to_gsheets()
    spreadsheet_key = 'xxxx'
    spreadsheet = gc.open_by_key(spreadsheet_key)
    worksheet = spreadsheet.worksheet("DATA")
    list_of_lists = worksheet.get_all_values()
    data=pd.DataFrame(list_of_lists)
    data.columns = data.iloc[0]
    return data
cost_data=read_cost_sheet()
print(cost_data)

 
I can't find what part of the script throws the error.

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Do you have a gateway installed and is Python installed on the gateway?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

8 REPLIES 8
JohnnyK
Advocate II
Advocate II

Use Python in Power Query Editor (it mentions the use of Gateway)

https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-python-in-query-editor

 

Use personal gateways in Power BI (it teaches how to install Gateway)

https://docs.microsoft.com/en-us/power-bi/connect-data/service-gateway-personal-mode

 

Anonymous
Not applicable

Adding this just in case the first solution doesn't work for other people:

- Something that works for me is in the PBI file change the privacy level for Python to "Private" and republish.

Greg_Deckler
Super User
Super User

Do you have a gateway installed and is Python installed on the gateway?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler,
I got the same type of Issue:

rameshmadhubhas_1-1694181270734.png

How can I sort this issue without using an On-premises data gateway?
Can I use the VNet data gateway to address this issue?

I did not, had not realized that was necessary, but I now installed it and it worked!

how did you do that. Thanks in advance

How can I install Python on the gateway?Thanks!

Great! 🙂


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.