Mac Mini M1.
Hi, I am trying to setup Google Calendar API. I followed every step explained in ...see documentation
When running the quickstart.py script given as sample (see here) I got errors :
Traceback (most recent call last):
File "/Users/matt/bin/scripts/calendar/quickstart.py", line 70, in <module>
main()
File "/Users/matt/bin/scripts/calendar/quickstart.py", line 32, in main
creds = flow.run_local_server(0)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/matt/bin/scripts/calendar/lib/python3.11/site-packages/google_auth_oauthlib/flow.py", line 432, in run_local_server
local_server = wsgiref.simple_server.make_server(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/wsgiref/simple_server.py", line 154, in make_server
server = server_class((host, port), handler_class)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/socketserver.py", line 456, in __init__
self.server_bind()
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/wsgiref/simple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/server.py", line 136, in server_bind
socketserver.TCPServer.server_bind(self)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/socketserver.py", line 472, in server_bind
self.socket.bind(self.server_address)
TypeError: str, bytes or bytearray expected, not int
What puzzles me is why the libs jump outside my virtual environment (set to '/Users/matt/bin/scripts/calendar') and referencing the system wide python3 (/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11) ?
I checked for a shell alias that could interfere... nope.
Any ideas ?
Thanks
The code in the quickstart.py is
creds = flow.run_local_server(port=0)
In your traceback the problematic line is creds = flow.run_local_server(0)
. Fix your code with port=0
.
Without keyword port
that 0
is passed as the 1st argument but the 1st argument for the function is host
. So your call is equivalent to .run_local_server(host=0)
but host
is expected to be a string — a host name or an IP address. Hence the error. Call .run_local_server(port=0)
is equivalent to .run_local_server(host='localhost', port=0)
.