Closed littleYaang closed 1 month ago
感谢你们的杰出贡献,但我在使用cn/demo_google.py时会报如下错误:
cn/demo_google.py
2024-03-27 08:57:36.493 | ERROR | __main__:<module>:40 - An error has been caught in function '<module>', process 'MainProcess' (1576451), thread 'MainThread' (140422575613760): Traceback (most recent call last): File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpx/_transports/default.py", line 66, in map_httpcore_exceptions yield File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpx/_transports/default.py", line 366, in handle_async_request resp = await self._pool.handle_async_request(req) │ │ │ └ <Request [b'GET']> │ │ └ <function AsyncConnectionPool.handle_async_request at 0x7fb6a8b9aca0> │ └ <AsyncHTTPProxy [Requests: 0 active, 0 queued | Connections: 0 active, 0 idle]> └ <httpx.AsyncHTTPTransport object at 0x7fb6a875c820> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 216, in handle_async_request raise exc from None File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 196, in handle_async_request response = await connection.handle_async_request( │ └ <function AsyncTunnelHTTPConnection.handle_async_request at 0x7fb6a8b9fb80> └ <AsyncTunnelHTTPConnection [CONNECTION FAILED]> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpcore/_async/http_proxy.py", line 289, in handle_async_request connect_response = await self._connection.handle_async_request( │ │ └ <function AsyncHTTPConnection.handle_async_request at 0x7fb6a8b96e50> │ └ <AsyncHTTPConnection [CONNECTION FAILED]> └ <AsyncTunnelHTTPConnection [CONNECTION FAILED]> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpcore/_async/connection.py", line 99, in handle_async_request raise exc File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpcore/_async/connection.py", line 76, in handle_async_request stream = await self._connect(request) │ │ └ <Request [b'CONNECT']> │ └ <function AsyncHTTPConnection._connect at 0x7fb6a8b96ee0> └ <AsyncHTTPConnection [CONNECTION FAILED]> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpcore/_async/connection.py", line 122, in _connect stream = await self._network_backend.connect_tcp(**kwargs) │ │ │ └ {'host': '127.0.0.1', 'port': 1081, 'local_address': None, 'timeout': 30, 'socket_options': None} │ │ └ <function AutoBackend.connect_tcp at 0x7fb6a8b8a310> │ └ <httpcore._backends.auto.AutoBackend object at 0x7fb6a875c970> └ <AsyncHTTPConnection [CONNECTION FAILED]> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpcore/_backends/auto.py", line 30, in connect_tcp return await self._backend.connect_tcp( │ │ └ <function AnyIOBackend.connect_tcp at 0x7fb6a8bb23a0> │ └ <httpcore.AnyIOBackend object at 0x7fb6a8774eb0> └ <httpcore._backends.auto.AutoBackend object at 0x7fb6a875c970> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpcore/_backends/anyio.py", line 121, in connect_tcp stream._raw_socket.setsockopt(*option) # type: ignore[attr-defined] # pragma: no cover File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/contextlib.py", line 131, in __exit__ self.gen.throw(type, value, traceback) │ │ │ │ │ └ <traceback object at 0x7fb6a86c6100> │ │ │ │ └ OSError('All connection attempts failed') │ │ │ └ <class 'OSError'> │ │ └ <method 'throw' of 'generator' objects> │ └ <generator object map_exceptions at 0x7fb6a8779eb0> └ <contextlib._GeneratorContextManager object at 0x7fb6a870c2e0> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions raise to_exc(exc) from exc └ <class 'httpcore.ConnectError'> httpcore.ConnectError: All connection attempts failed The above exception was the direct cause of the following exception: Traceback (most recent call last): > File "demo_google.py", line 40, in <module> test_sync() └ <function test_sync at 0x7fb6a8753c10> File "demo_google.py", line 15, in test_sync resp = google.search(url=url) │ │ └ 'https://raw.githubusercontent.com/kitUIN/PicImageSearch/main/demo/images/test03.jpg' │ └ <function Google.search at 0x7fb6a874fe50> └ <PicImageSearch.google.Google object at 0x7fb6a8751b50> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/PicImageSearch/sync.py", line 34, in syncified return coro if loop.is_running() else loop.run_until_complete(coro) │ │ │ │ │ └ <coroutine object Google.search at 0x7fb6a87b73c0> │ │ │ │ └ <function BaseEventLoop.run_until_complete at 0x7fb6abf54af0> │ │ │ └ <_UnixSelectorEventLoop running=False closed=False debug=False> │ │ └ <function BaseEventLoop.is_running at 0x7fb6abf54dc0> │ └ <_UnixSelectorEventLoop running=False closed=False debug=False> └ <coroutine object Google.search at 0x7fb6a87b73c0> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete return future.result() │ └ <method 'result' of '_asyncio.Task' objects> └ <Task finished name='Task-1' coro=<Google.search() done, defined at /home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/s... File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/PicImageSearch/google.py", line 95, in search resp = await self.get(self.base_url, params=params) │ │ │ │ └ {'sbisrc': 1, 'image_url': 'https://raw.githubusercontent.com/kitUIN/PicImageSearch/main/demo/images/test03.jpg'} │ │ │ └ 'https://www.google.com/searchbyimage' │ │ └ <PicImageSearch.google.Google object at 0x7fb6a8751b50> │ └ <function HandOver.get at 0x7fb6a874fc10> └ <PicImageSearch.google.Google object at 0x7fb6a8751b50> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/PicImageSearch/network.py", line 200, in get resp = await client.get(url, params=params, **kwargs) │ │ │ │ └ {} │ │ │ └ {'sbisrc': 1, 'image_url': 'https://raw.githubusercontent.com/kitUIN/PicImageSearch/main/demo/images/test03.jpg'} │ │ └ 'https://www.google.com/searchbyimage' │ └ <function AsyncClient.get at 0x7fb6a8b46040> └ <httpx.AsyncClient object at 0x7fb6a875c0a0> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpx/_client.py", line 1757, in get return await self.request( │ └ <function AsyncClient.request at 0x7fb6a8b42c10> └ <httpx.AsyncClient object at 0x7fb6a875c0a0> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpx/_client.py", line 1530, in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) │ │ │ │ └ <httpx._client.UseClientDefault object at 0x7fb6a8fc56a0> │ │ │ └ <httpx._client.UseClientDefault object at 0x7fb6a8fc56a0> │ │ └ <Request('GET', 'https://www.google.com/searchbyimage?sbisrc=1&image_url=https%3A%2F%2Fraw.githubusercontent.com%2FkitUIN%2FP... │ └ <function AsyncClient.send at 0x7fb6a8b42dc0> └ <httpx.AsyncClient object at 0x7fb6a875c0a0> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpx/_client.py", line 1617, in send response = await self._send_handling_auth( │ └ <function AsyncClient._send_handling_auth at 0x7fb6a8b42e50> └ <httpx.AsyncClient object at 0x7fb6a875c0a0> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpx/_client.py", line 1645, in _send_handling_auth response = await self._send_handling_redirects( │ └ <function AsyncClient._send_handling_redirects at 0x7fb6a8b42ee0> └ <httpx.AsyncClient object at 0x7fb6a875c0a0> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpx/_client.py", line 1682, in _send_handling_redirects response = await self._send_single_request(request) │ │ └ <Request('GET', 'https://www.google.com/searchbyimage?sbisrc=1&image_url=https%3A%2F%2Fraw.githubusercontent.com%2FkitUIN%2FP... │ └ <function AsyncClient._send_single_request at 0x7fb6a8b42f70> └ <httpx.AsyncClient object at 0x7fb6a875c0a0> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpx/_client.py", line 1719, in _send_single_request response = await transport.handle_async_request(request) │ │ └ <Request('GET', 'https://www.google.com/searchbyimage?sbisrc=1&image_url=https%3A%2F%2Fraw.githubusercontent.com%2FkitUIN%2FP... │ └ <function AsyncHTTPTransport.handle_async_request at 0x7fb6a8bb63a0> └ <httpx.AsyncHTTPTransport object at 0x7fb6a875c820> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpx/_transports/default.py", line 366, in handle_async_request resp = await self._pool.handle_async_request(req) │ │ │ └ <Request [b'GET']> │ │ └ <function AsyncConnectionPool.handle_async_request at 0x7fb6a8b9aca0> │ └ <AsyncHTTPProxy [Requests: 0 active, 0 queued | Connections: 0 active, 0 idle]> └ <httpx.AsyncHTTPTransport object at 0x7fb6a875c820> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/contextlib.py", line 131, in __exit__ self.gen.throw(type, value, traceback) │ │ │ │ │ └ <traceback object at 0x7fb6a86c6480> │ │ │ │ └ ConnectError(OSError('All connection attempts failed')) │ │ │ └ <class 'httpcore.ConnectError'> │ │ └ <method 'throw' of 'generator' objects> │ └ <generator object map_httpcore_exceptions at 0x7fb6a8799f20> └ <contextlib._GeneratorContextManager object at 0x7fb6a875cb20> File "/home/v-qinyang/miniconda3/envs/openmmlab/lib/python3.8/site-packages/httpx/_transports/default.py", line 83, in map_httpcore_exceptions raise mapped_exc(message) from exc │ └ 'All connection attempts failed' └ <class 'httpx.ConnectError'> httpx.ConnectError: All connection attempts failed
但是其余的demo_x.py能够正常使用,网页也能够正常打开google网址。
你有检查用于配置代理的 proxies 变量吗?演示代码里的代理地址是本机的 1081 端口,这点从日志里也能看出来。
proxies
如果你的网络环境不需要代理,请将其设置为 None。否则,请将其更改为你正在使用的代理地址。
None
好吧,我弄错了。演示代码里的是 1080 。不过看样子还是网络环境问题,你换个节点试试?
根据这个 issue #126 ,可能是你所在网络的 DNS 出了问题,你更换后再试试吧。
感谢你们的杰出贡献,但我在使用
cn/demo_google.py
时会报如下错误:但是其余的demo_x.py能够正常使用,网页也能够正常打开google网址。