我刚在我的mac上安装了AIOHTTP
Python 3.10.8
Visual代码版本: 1.72.2
Package Version
------------------ -------
aiodns 3.0.0
aiohttp 3.8.3
aiosignal 1.2.0
async-timeout 4.0.2
attrs 22.1.0
cffi 1.15.1
charset-normalizer 2.1.1
frozenlist 1.3.1
idna 3.4
multidict 6.0.2
pip 22.3
pycares 4.2.2
pycparser 2.21
setuptools 65.5.0
wheel 0.37.1
yarl 1.8.1例如。代码
import aiohttp
import asyncio
async def main():
async with aiohttp.ClientSession() as session:
async with session.get('http://python.org') as response:
print("Status:", response.status)
print("Content-type:", response.headers['content-type'])
html = await response.text()
print("Body:", html[:15], "...")
loop = asyncio.get_event_loop()
loop.run_until_complete(main())当我试图运行客户端示例之上的代码时,我得到了很多错误,这只是其中的几个。我错过了什么?
test.py:15: DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop()
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host python.org:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate https://stackoverflow.com/questions/74261872
复制相似问题