Google 工作表 API 无法在 PythonAnywhere 上运行

Google Sheets API not working on PythonAnywhere

我在 PythonAnywhere 上有一个 Flask 网络应用程序 运行,它使用 Google 张 API。在开发过程中,一切顺利,但是当在 PythonAnywhere 上的 Beginner Account 上部署到生产环境时,出现了这个错误:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/diyaassessments/dal_assessments/main.py", line 736, in new_test
    test_data = create_new_test_sheet(flask.session['username'])
  File "/home/diyaassessments/dal_assessments/main.py", line 214, in create_new_test_sheet
    sheet_id = sheets_api.create_sheet(test_id, gauth.load_credentials())
  File "/home/diyaassessments/dal_assessments/sheets_api.py", line 50, in create_sheet
    service = build('sheets', 'v4', credentials=credentials)
  File "/home/diyaassessments/.local/lib/python3.8/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/diyaassessments/.local/lib/python3.8/site-packages/googleapiclient/discovery.py", line 270, in build
    content = _retrieve_discovery_doc(
  File "/home/diyaassessments/.local/lib/python3.8/site-packages/googleapiclient/discovery.py", line 376, in _retrieve_discovery_doc
    resp, content = req.execute(num_retries=num_retries)
  File "/home/diyaassessments/.local/lib/python3.8/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/diyaassessments/.local/lib/python3.8/site-packages/googleapiclient/http.py", line 900, in execute
    resp, content = _retry_request(
  File "/home/diyaassessments/.local/lib/python3.8/site-packages/googleapiclient/http.py", line 177, in _retry_request
    resp, content = http.request(uri, method, *args, **kwargs)
  File "/home/diyaassessments/.local/lib/python3.8/site-packages/httplib2/__init__.py", line 1985, in request
    (response, content) = self._request(
  File "/home/diyaassessments/.local/lib/python3.8/site-packages/httplib2/__init__.py", line 1650, in _request
    (response, content) = self._conn_request(
  File "/home/diyaassessments/.local/lib/python3.8/site-packages/httplib2/__init__.py", line 1557, in _conn_request
    conn.connect()
  File "/home/diyaassessments/.local/lib/python3.8/site-packages/httplib2/__init__.py", line 1324, in connect
    sock.connect((self.host, self.port))
  File "/usr/lib/python3.8/site-packages/socks.py", line 406, in connect
    self.__negotiatehttp(destpair[0],destpair[1])
  File "/usr/lib/python3.8/site-packages/socks.py", line 357, in __negotiatehttp
    while resp.find("\r\n\r\n")==-1:
TypeError: argument should be integer or bytes-like object, not 'str'

我从来没有见过这种错误。发生这种情况是因为 PythonAnywhere 阻止了对大多数外部站点的请求吗?或者它是代码中的错误(尽管它在开发过程中运行良好)?
请帮助我。
谢谢。

根据 that 使用 pip3.8 install --user --force-reinstall PySocks 升级 PySocs 应该会有所帮助。