1

我使用了项目描述页面中的代码并将 .yml 文件移动到我的主目录。

编码:

from morningstar.morningstar_client import MorningstarClient

client = MorningstarClient()

print(client.provider.search({'isin': "CH0038863350"}))

当我运行程序时,它会运行一段时间并返回此错误:

    /Users/denton/.virtualenvs/financials/bin/python /Users/denton/PycharmProjects/financials/morning.py
Traceback (most recent call last):
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/urllib3/connection.py", line 159, in _new_conn
    conn = connection.create_connection(
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 60] Operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/urllib3/connectionpool.py", line 392, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1230, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1276, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1225, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1004, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 944, in send
    self.connect()
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/urllib3/connection.py", line 187, in connect
    conn = self._new_conn()
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/urllib3/connection.py", line 171, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fcc8c4b6c10>: Failed to establish a new connection: [Errno 60] Operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/urllib3/connectionpool.py", line 724, in urlopen
    retries = retries.increment(
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/urllib3/util/retry.py", line 439, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='msxml.tenfore.com', port=80): Max retries exceeded with url: /search?username=foo&password=bar&isin=CH0038863350&json (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fcc8c4b6c10>: Failed to establish a new connection: [Errno 60] Operation timed out'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/denton/PycharmProjects/financials/morning.py", line 16, in <module>
    print(client.provider.search({'isin': "CH0038863350"}))
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/morningstar/provider/morningstar.py", line 58, in search
    response = self._tenfore('search', params)
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/morningstar/provider/morningstar.py", line 43, in _tenfore
    return self._request(base=base, params=params)
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/morningstar/provider/morningstar.py", line 38, in _request
    response = requests.get(self._build_url(base=base, params=params))
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/Users/denton/.virtualenvs/financials/lib/python3.8/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='msxml.tenfore.com', port=80): Max retries exceeded with url: /search?username=foo&password=bar&isin=CH0038863350&json (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fcc8c4b6c10>: Failed to establish a new connection: [Errno 60] Operation timed out'))

Process finished with exit code 1

我是一个超级菜鸟,不明白错误或它在说什么,除了连接不正确(?)。我将不胜感激任何帮助。谢谢。

4

0 回答 0