lemonhu / stock-knowledge-graph

利用网络上公开的数据构建一个小型的证券知识图谱/知识库
MIT License
2.01k stars 597 forks source link

Stock.py报错 #19

Open TTiger-chen opened 3 years ago

TTiger-chen commented 3 years ago

使用了tushare工具后会报以下两条错误: 1.socket.gaierror: [Errno 11001] getaddrinfo failed 2.urllib.error.URLError: <urlopen error [Errno 11001] getaddrinfo failed> 求解答!!!感谢感谢 Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 1346, in do_open h.request(req.get_method(), req.selector, req.data, headers, File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1255, in request self._send_request(method, url, body, headers, encode_chunked) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1301, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1250, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1010, in _send_output self.send(msg) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 950, in send self.connect() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 921, in connect self.sock = self._create_connection( File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\socket.py", line 822, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\socket.py", line 953, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "D:\stock.py", line 37, in df_industry = ts.get_industry_classified() File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\tushare\stock\classifying.py", line 49, in get_industry_classified df = pd.read_csv(ct.TSDATA_CLASS%(ct.P_TYPE['http'], ct.DOMAINS['oss'], 'industry'), File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\pandas\io\parsers.py", line 610, in read_csv return _read(filepath_or_buffer, kwds) File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\pandas\io\parsers.py", line 462, in _read parser = TextFileReader(filepath_or_buffer, kwds) File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\pandas\io\parsers.py", line 819, in init self._engine = self._make_engine(self.engine) File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\pandas\io\parsers.py", line 1050, in _make_engine return mapping[engine](self.f, self.options) # type: ignore[call-arg] File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\pandas\io\parsers.py", line 1867, in init self._open_handles(src, kwds) File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\pandas\io\parsers.py", line 1362, in _open_handles self.handles = get_handle( File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\pandas\io\common.py", line 558, in get_handle ioargs = _get_filepath_or_buffer( File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\pandas\io\common.py", line 289, in _get_filepath_or_buffer req = urlopen(filepath_or_buffer) File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\pandas\io\common.py", line 195, in urlopen return urllib.request.urlopen(*args, *kwargs) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 214, in urlopen return opener.open(url, data, timeout) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 517, in open response = self._open(req, data) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 534, in _open result = self._call_chain(self.handle_open, protocol, protocol + File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 494, in _call_chain result = func(args) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 1375, in http_open return self.do_open(http.client.HTTPConnection, req) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 1349, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [Errno 11001] getaddrinfo failed>

JukieChen commented 3 years ago

似乎是因为tushare社区现在发布了pro版,数据接口和权限都有所变化,具体可见https://waditu.com/document/1?doc_id=129