I am currently working on a python script to access the youtube data api v3. The script works just fine inside vscode (Windows 11 pro, Python 3.10.6 x64). This test script is not the one i am working on but it is enough to reproduce the error.
from urllib import request, responsefrom googleapiclient import discoveryyoutube = discovery.build("youtube", "v3", developerKey="my api key")request = youtube.search().list( part="snippet", type="channel", q="mrbeast", maxResults=1 )response = request.execute()print(response["items"][0]["snippet"]["title"])
I converted the script to an .exe via
PS C:\Users\USER\Desktop\Python projects> pyinstaller --onefile api_test.py
and it worked just fine. However, when i execute it within PS, i get this strange error message:
PS C:\Users\USER\Desktop\Python projects\dist> ./api_test.exeTraceback (most recent call last): File "api_test.py", line 4, in <module> File "googleapiclient\_helpers.py", line 130, in positional_wrapper File "googleapiclient\discovery.py", line 287, in build File "googleapiclient\discovery.py", line 404, in _retrieve_discovery_docgoogleapiclient.errors.UnknownApiNameOrVersion: name: youtube version: v3[20192] Failed to execute script 'api_test' due to unhandled exception!
How can this happen and has anyone an idea how to resolve this issue?
Thanks in advance.