goldsmith / Wikipedia

A Pythonic wrapper for the Wikipedia API
https://wikipedia.readthedocs.org/
MIT License
2.89k stars 519 forks source link

While using Voice Recognition I'm getting this error. #242

Open sparsh9 opened 4 years ago

sparsh9 commented 4 years ago

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen httplib_response = self._make_request( File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request httplib_response = conn.getresponse() File "/usr/lib/python3.8/http/client.py", line 1332, in getresponse response.begin() File "/usr/lib/python3.8/http/client.py", line 303, in begin version, status, reason = self._read_status() File "/usr/lib/python3.8/http/client.py", line 272, in _read_status raise RemoteDisconnected("Remote end closed connection without" http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send resp = conn.urlopen( File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen retries = retries.increment( File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 400, in increment raise six.reraise(type(error), error, _stacktrace) File "/usr/lib/python3/dist-packages/six.py", line 702, in reraise raise value.with_traceback(tb) File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen httplib_response = self._make_request( File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request httplib_response = conn.getresponse() File "/usr/lib/python3.8/http/client.py", line 1332, in getresponse response.begin() File "/usr/lib/python3.8/http/client.py", line 303, in begin version, status, reason = self._read_status() File "/usr/lib/python3.8/http/client.py", line 272, in _read_status raise RemoteDisconnected("Remote end closed connection without" urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/logan/PycharmProjects/Friday/fri.py", line 80, in results = wikipedia.summary(query, sentences=2) File "/home/logan/.local/lib/python3.8/site-packages/wikipedia/util.py", line 28, in call ret = self._cache[key] = self.fn(*args, kwargs) File "/home/logan/.local/lib/python3.8/site-packages/wikipedia/wikipedia.py", line 231, in summary page_info = page(title, auto_suggest=auto_suggest, redirect=redirect) File "/home/logan/.local/lib/python3.8/site-packages/wikipedia/wikipedia.py", line 276, in page return WikipediaPage(title, redirect=redirect, preload=preload) File "/home/logan/.local/lib/python3.8/site-packages/wikipedia/wikipedia.py", line 299, in init self.load(redirect=redirect, preload=preload) File "/home/logan/.local/lib/python3.8/site-packages/wikipedia/wikipedia.py", line 336, in load request = _wiki_request(query_params) File "/home/logan/.local/lib/python3.8/site-packages/wikipedia/wikipedia.py", line 737, in _wiki_request r = requests.get(API_URL, params=params, headers=headers) File "/usr/lib/python3/dist-packages/requests/api.py", line 75, in get return request('get', url, params=params, kwargs) File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in request return session.request(method=method, url=url, kwargs) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request resp = self.send(prep, send_kwargs) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send r = adapter.send(request, **kwargs) File "/usr/lib/python3/dist-packages/requests/adapters.py", line 498, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

using this code -- elif "wikipedia" in query: speak("Searching...") query = query.replace("wikipedia", " ") results = wikipedia.summary(query, sentences=2) print("According to Wikipedia") print(results)

alphapapa commented 4 years ago

You should provide a https://en.wikipedia.org/wiki/Minimal_working_example and use appropriate formatting.