aiohttp - running client example "RuntimeError: SSL is not supported"
aiohttp - running client example "RuntimeError: SSL is not supported"
我只是想通过 aiohttp 示例,但我在第一个示例中遇到错误:
import aiohttp
import asyncio
async def fetch(session, url):
async with session.get(url) as response:
return await response.text()
async def main():
async with aiohttp.ClientSession() as session:
html = await fetch(session, 'http://python.org')
print(html)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
运行 这让我明白了:
File "C:\ProgramData\Anaconda2\envs\asyncio\lib\site-packages\aiohttp\connector.py", line 887, in _get_ssl_context
raise RuntimeError('SSL is not supported.')
RuntimeError: SSL is not supported.
- Python版本:3.7.3
- aiohttp 版本:3.5.4
我搜索了正在复制的问题,但找不到任何内容...这让我认为我的设置有问题。我 运行 在 Windows 8.1 上使用 Anaconda2 环境
怎么回事?
Aiohttp 导入 ssl
as follows:
try:
import ssl
SSLContext = ssl.SSLContext
except ImportError: # pragma: no cover
ssl = None # type: ignore
SSLContext = object # type: ignore
如果它仍然是 None
,则会出现您 post 中指定的错误。因此,首先尝试手动 import ssl
。它看起来应该有点像:
>>> import ssl
>>> ssl
<module 'ssl' from '/usr/lib/python3.6/ssl.py'>
如果没有,则 check/reinstall 您的 python 设置。
我只是想通过 aiohttp 示例,但我在第一个示例中遇到错误:
import aiohttp
import asyncio
async def fetch(session, url):
async with session.get(url) as response:
return await response.text()
async def main():
async with aiohttp.ClientSession() as session:
html = await fetch(session, 'http://python.org')
print(html)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
运行 这让我明白了:
File "C:\ProgramData\Anaconda2\envs\asyncio\lib\site-packages\aiohttp\connector.py", line 887, in _get_ssl_context raise RuntimeError('SSL is not supported.') RuntimeError: SSL is not supported.
- Python版本:3.7.3
- aiohttp 版本:3.5.4
我搜索了正在复制的问题,但找不到任何内容...这让我认为我的设置有问题。我 运行 在 Windows 8.1 上使用 Anaconda2 环境
怎么回事?
Aiohttp 导入 ssl
as follows:
try:
import ssl
SSLContext = ssl.SSLContext
except ImportError: # pragma: no cover
ssl = None # type: ignore
SSLContext = object # type: ignore
如果它仍然是 None
,则会出现您 post 中指定的错误。因此,首先尝试手动 import ssl
。它看起来应该有点像:
>>> import ssl
>>> ssl
<module 'ssl' from '/usr/lib/python3.6/ssl.py'>
如果没有,则 check/reinstall 您的 python 设置。