Forums

Error while setting up a task with google's api

I am able to run my program in a console but it does not work when i set up a task

Traceback (most recent call last):
  File "/home/Z3R0C1PH3R2/youtube/main.py", line 56, in <module>
    resp = upload.upload_video(f"{data['title']} #shorts", f"{date} APOD update-\n{text}\n\nImage- {data['hdurl'] if 'hdurl' in data else data['url']}\nVoice using Aws Polly\n\nUploaded Automatically by a program, an experiment by Z3R0C1PH3R", vidn)
  File "/home/Z3R0C1PH3R2/youtube/upload.py", line 11, in upload_video
    service = Create_Service(CLIENT_SECRET_FILE, API_NAME, API_VERSION, SCOPES)
  File "/home/Z3R0C1PH3R2/youtube/Google.py", line 31, in Create_Service
    cred = flow.run_local_server()
  File "/home/Z3R0C1PH3R2/.local/lib/python3.8/site-packages/google_auth_oauthlib/flow.py", line 457, in run_local_server
    local_server = wsgiref.simple_server.make_server(
  File "/usr/lib/python3.8/wsgiref/simple_server.py", line 154, in make_server
    server = server_class((host, port), handler_class)
  File "/usr/lib/python3.8/socketserver.py", line 452, in __init__
    self.server_bind()
  File "/usr/lib/python3.8/wsgiref/simple_server.py", line 50, in server_bind
    HTTPServer.server_bind(self)
  File "/usr/lib/python3.8/http/server.py", line 137, in server_bind
    socketserver.TCPServer.server_bind(self)
  File "/usr/lib/python3.8/socketserver.py", line 466, in server_bind
    self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use

2022-01-21 08:11:50 -- Completed task, took 43.28 seconds, return code was 1.

From the traceback message I guess that your code is trying to start a server -- that would not work in terms of being visible to the external world (the same for the console and the task). What do you mean by being able to run the code in the console? Is the code doing what you intended it to in the console but not in the task?

Yes, the code works in the console but fails when i use the same thing with a task, the program is using Google's api to upload a youtube video

If it's trying to start a server on some specific port, then whether or not it will run will depend on whether someone else is already using the port in question. So if there's some way to tell the library that you're usng to use a different port, that should help. However, given that the server that it is starting will be inaccessible from outside PythonAnywhere, and also given that it works in a console even though the server is inaccessible, perhaps that server is not an essential part of what the library is trying to do? There might be some kind of configuration for the library you can do that will tell it to not bother with the server side portion.