Python wsgi: ssl-error Cannot connect to HTTPS address because SSL module is not available

I just switched from an Amazon ec2 instance to a drop of DigitalOcean. Everything seems to be working fine until I ran into an SSL problem while setting up my python, WSGI and apache2 application.

Drop: Ubuntu 16.04 Python Version: 2.7.12

Virtualhost File

WSGISocketPrefix /var/run/wsgi                                                           
<VirtualHost *:80>                                                                       
ServerName c123456.com                                                               
#translatr.varunmalhotra.xyz                                                         

#DocumentRoot /var/www/html                                                          
#ErrorDocument 404 /notFound404.html                                                 
ErrorLog /var/log/translatr.error.log                                                
CustomLog /var/log/translatr.access.log combined                                     

WSGIDaemonProcess translatrapp python-path=/var/www/html/translatr:/var/www/html/translatr/ENV/lib/python2.7/site-packages                                                    
WSGIScriptAlias / /var/www/html/translatr/translatrapp.wsgi                          

<Directory /var/www/html/translatr>                                                  
    WSGIProcessGroup translatrapp                                                    
    WSGIApplicationGroup %{GLOBAL}                                                   
    Order deny,allow                                                                 
    Allow from all                                                                   
</Directory>                                                                         


`` ``

My application uses the python module requeststo create a GET request. Requests are returned 500, and when I check my logs, I could see

[Sat Jan 28 10:46:23.754636 2017] [wsgi:error] [pid 6627:tid 139754554279680]     request
 = requests.get(link, headers=agents, verify=False)                                      
[Sat Jan 28 10:46:23.754641 2017] [wsgi:error] [pid 6627:tid 139754554279680]   File "/va
r/www/html/translatr/ENV/lib/python2.7/site-packages/requests/api.py", line 69, in get   
[Sat Jan 28 10:46:23.754645 2017] [wsgi:error] [pid 6627:tid 139754554279680]     return 
request('get', url, params=params, **kwargs)                                             
[Sat Jan 28 10:46:23.754650 2017] [wsgi:error] [pid 6627:tid 139754554279680]   File "/va
r/www/html/translatr/ENV/lib/python2.7/site-packages/requests/api.py", line 50, in reques
t                                                                                        
[Sat Jan 28 10:46:23.754655 2017] [wsgi:error] [pid 6627:tid 139754554279680]     respons
e = session.request(method=method, url=url, **kwargs)                                    
[Sat Jan 28 10:46:23.754659 2017] [wsgi:error] [pid 6627:tid 139754554279680]   File "/va
r/www/html/translatr/ENV/lib/python2.7/site-packages/requests/sessions.py", line 468, in 
request                                                                                  
[Sat Jan 28 10:46:23.754664 2017] [wsgi:error] [pid 6627:tid 139754554279680]     resp = 
self.send(prep, **send_kwargs)                                                           
[Sat Jan 28 10:46:23.754669 2017] [wsgi:error] [pid 6627:tid 139754554279680]   File "/va
r/www/html/translatr/ENV/lib/python2.7/site-packages/requests/sessions.py", line 597, in 
send                                                                                     
[Sat Jan 28 10:46:23.754673 2017] [wsgi:error] [pid 6627:tid 139754554279680]     history
 = [resp for resp in gen] if allow_redirects else []                                     
[Sat Jan 28 10:46:23.754678 2017] [wsgi:error] [pid 6627:tid 139754554279680]   File "/va
r/www/html/translatr/ENV/lib/python2.7/site-packages/requests/sessions.py", line 195, in 
resolve_redirects                                                                        
[Sat Jan 28 10:46:23.754683 2017] [wsgi:error] [pid 6627:tid 139754554279680]     **adapt
er_kwargs                                                                                
[Sat Jan 28 10:46:23.754687 2017] [wsgi:error] [pid 6627:tid 139754554279680]   File "/va
r/www/html/translatr/ENV/lib/python2.7/site-packages/requests/sessions.py", line 576, in 
send                                                                                     
[Sat Jan 28 10:46:23.754692 2017] [wsgi:error] [pid 6627:tid 139754554279680]     r = ada
pter.send(request, **kwargs)                                                             
[Sat Jan 28 10:46:23.754697 2017] [wsgi:error] [pid 6627:tid 139754554279680]   File "/va
r/www/html/translatr/ENV/lib/python2.7/site-packages/requests/adapters.py", line 433, in 
send                                                                                     
[Sat Jan 28 10:46:23.754702 2017] [wsgi:error] [pid 6627:tid 139754554279680]     raise S
SLError(e, request=request)                                                              │
[Sat Jan 28 10:46:23.754706 2017] [wsgi:error] [pid 6627:tid 139754554279680] SSLError: C│
an't connect to HTTPS URL because the SSL module is not available.

I searched a lot. I tried to install openssl, another conf, but very upset. I do not know how it works smoothly in Amazon ec2, but not in Droplet.

Any help in a good direction would be appreciated. Thanks

+4
3

, - python. python, . Ubuntu 16.04 digitalOcean machine, python. . , https://askubuntu.com/questions/101591/how-do-i-install-python-2-7-2-on-ubuntu

.

, , Ubuntu 14.04, python. Flask, .

Ubuntu 16.04 ( python) Ubuntu 14.04 ( python).

+1

Python ,

./configure
make
sudo checkinstall

, openssl ( sudo apt install openssl).

+4

After installing openssl and opessl-devel, there is no need to configure python again.

Run the following commands:

make 
make install
-1
source

Source: https://habr.com/ru/post/1668093/


All Articles