I have just installed AIOHTTP on my mac
Python 3.10.8
Visual Studio Code Version: 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
Ex. code
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())
When I try to run the code above Client example I getting lot of errors, this is just a few of them. What do I miss?
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
2
Answers
I found the answer. The Getting Started Client example does not work with 3.10....
Switch between 3.9 and 3.10 is easy way to reproduce the error...
As per this,
This is something similar to
verify=False
inrequests
library.