6

I installed python 3.6 from source. Python seems working fine but I'm unable to import openssl 1.1.1 (a pre-release that I need to use). I think that there is a path issue but not sure. When I try to import ssl from python, this is the output I get:

~/Downloads/Python-3.6.5$ python3
Python 3.6.5 (default, May  9 2018, 15:43:39) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  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' 

Any suggestions?

When I installed openssl, I grabbed the source code then:

./config
sudo make
sudo make install 

It seems that openssl has been installed correctly. The output is mostly similar to this path:

/usr/local/share/man/man5/config.5

I then Then uncommented these two lines in Python-3.6.5/Module/Setup.dist

_socket socketmodule.c

And

# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:

SSL=/usr/local/ssl
_ssl _ssl.c \
    -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
    -L$(SSL)/lib -lssl -lcrypto

Then, When I try to import ssl in python, I get this error:

Python 3.6.5 (default, May  9 2018, 15:43:39) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  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'

Can you please help? What can be the cause of the problem?

user9371654
  • 2,160
  • 16
  • 45
  • 78
  • 4
    @Patrick Haugh this is not a duplicate question. The answer in the link you provided dates back to 2011 and suggest using `--with-ssl` which is not applicable to python 3.6 as newer answers in the same link suggest. – user9371654 May 10 '18 at 06:16

0 Answers0