1

The aiohttp module was installed successfully

But can not be imported as below info

[root@ceph_admin ~]# python3 
Python 3.6.5 (default, Jul  1 2018, 23:52:30) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import  aiohttp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/aiohttp/__init__.py", line 6, in <module>
    from .client import *  # noqa
  File "/usr/local/lib/python3.6/site-packages/aiohttp/client.py", line 17, in <module>
    from . import client_exceptions, client_reqrep
  File "/usr/local/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 17, in <module>
    from . import hdrs, helpers, http, multipart, payload
  File "/usr/local/lib/python3.6/site-packages/aiohttp/helpers.py", line 40, in <module>
    import idna_ssl
  File "/usr/local/lib/python3.6/site-packages/idna_ssl.py", line 1, in <module>
    import ssl
  File "/usr/local/lib/python3.6/ssl.py", line 101, in <module>
    import _ssl             # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'
Kramer Li
  • 2,284
  • 5
  • 27
  • 55
  • How did you install python? Did you build it yourself? https://stackoverflow.com/questions/5128845/importerror-no-module-named-ssl – Patrick Haugh Jul 02 '18 at 02:10

1 Answers1

1

The error above is

ModuleNotFoundError: No module named '_ssl'

So the real problem is my python3 can not import the module _ssl

My python 3.5 was installed from source code. Below are the correct ways to make python 3.5 have _ssl.

1. install openssl-devel by yum(My OS is CentOS)
2. compile your python source code with command (./configure && make && make install)
Kramer Li
  • 2,284
  • 5
  • 27
  • 55