# Raise Exception("Cannot import pyOpenSSL")

**URL:** <https://forum.ansible.com/t/raise-exception-cannot-import-pyopenssl/23939>\
**Category:** Ansible Project\
**Tags:** windows, rhel\
**Created:** [March 11, 2017, 7:46pm UTC](https://forum.ansible.com/t/raise-exception-cannot-import-pyopenssl/23939 "2017-03-11T19:46:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tiago\_Pimpao](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@Tiago\_Pimpao](https://forum.ansible.com/u/Tiago_Pimpao)\
**Post date:** [March 11, 2017, 7:46pm UTC](https://forum.ansible.com/t/raise-exception-cannot-import-pyopenssl/23939/1 "2017-03-11T19:46:31Z")

</div>

Hi there,  
I’m getting this error when running ansible.

[root@localhost ansible]# ansible windows -i hosts -m win\_ping -vvv  
Using /etc/ansible/ansible.cfg as config file  
An exception occurred during task execution. The full traceback is:  
Traceback (most recent call last):  
File “/usr/lib/python2.7/site-packages/ansible/executor/task\_executor.py”, line 126, in run  
res = self.\_execute()  
File “/usr/lib/python2.7/site-packages/ansible/executor/task\_executor.py”, line 453, in \_execute  
self.\_connection = self.\_get\_connection(variables=variables, templar=templar)  
File “/usr/lib/python2.7/site-packages/ansible/executor/task\_executor.py”, line 699, in \_get\_connection  
connection = self.\_shared\_loader\_obj.connection\_loader.get(conn\_type, self.\_play\_context, self.\_new\_stdin)  
File “/usr/lib/python2.7/site-packages/ansible/plugins/ **init**.py”, line 339, in get  
self.\_module\_cache[path] = self.\_load\_module\_source(‘.’.join([self.package, name]), path)  
File “/usr/lib/python2.7/site-packages/ansible/plugins/ **init**.py”, line 324, in \_load\_module\_source  
module = imp.load\_source(name, path, module\_file)  
File “/usr/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py”, line 46, in   
import winrm  
File “/usr/lib/python2.7/site-packages/winrm/ **init**.py”, line 6, in   
from winrm.protocol import Protocol  
File “/usr/lib/python2.7/site-packages/winrm/protocol.py”, line 11, in   
from winrm.transport import Transport  
File “/usr/lib/python2.7/site-packages/winrm/transport.py”, line 42, in   
from requests\_credssp import HttpCredSSPAuth  
File “/usr/lib/python2.7/site-packages/requests\_credssp/ **init**.py”, line 1, in   
from .credssp import HttpCredSSPAuth  
File “/usr/lib/python2.7/site-packages/requests\_credssp/credssp.py”, line 8, in   
raise Exception(“Cannot import pyOpenSSL”)  
Exception: Cannot import pyOpenSSL

[windows2012.contoso.com](http://windows2012.contoso.com) | FAILED! =\> {  
“failed”: true,  
“msg”: “Unexpected failure during module execution.”,  
“stdout”: “”  
}

I check everthying but not able to pass this error.

The SO wis a RHEL 7.3

thanks  
Tiago

---

<div class="post-metadata">

**Author:** ![Sumanth\_Reddy](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@Sumanth\_Reddy](https://forum.ansible.com/u/Sumanth_Reddy)\
**Post date:** [March 14, 2017, 1:15pm UTC](https://forum.ansible.com/t/raise-exception-cannot-import-pyopenssl/23939/2 "2017-03-14T13:15:39Z")

</div>

I have the same issue

---

<div class="post-metadata">

**Author:** ![cupcake](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@cupcake](https://forum.ansible.com/u/cupcake)\
**Post date:** [March 16, 2017, 3:50pm UTC](https://forum.ansible.com/t/raise-exception-cannot-import-pyopenssl/23939/3 "2017-03-16T15:50:56Z")

</div>

might want to run with -vvvvv to get winrm info as well; what auth are you doing.

I saw a similar issue and when i tried to user kerberos auth to AD

some version of pyopenssl was installed so i tried to upgrade.

`  
pip install pyopenssl --upgrade

`

received some errors with openssl/opensslv.h.  
`  
yum provides ‘\*openssl/opensslv.h’

`

and found it was part of package **openssl-devel** (rhel7 here)

After that I was able to connect with kerberos AD account.

Basic auth was working fine already.

---

<div class="post-metadata">

**Author:** ![Karthik\_Bhat](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@Karthik\_Bhat](https://forum.ansible.com/u/Karthik_Bhat)\
**Post date:** [September 8, 2017, 11:53am UTC](https://forum.ansible.com/t/raise-exception-cannot-import-pyopenssl/23939/4 "2017-09-08T11:53:54Z")

</div>

If you are on Ubuntu:  
sudo apt-get install libffi-dev  
pip install cryptography

Good luck!

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [September 8, 2017, 12:02pm UTC](https://forum.ansible.com/t/raise-exception-cannot-import-pyopenssl/23939/5 "2017-09-08T12:02:56Z")

</div>

Hey

The package pyOpenSSL is used by the requests-credssp package. Even if you are not using CredSSP it will try and load the library if it is there and fail if it doesn't exist. There is a newer version of requests-credssp that doesn't fail outright if you aren't using credssp auth so try pip install -U requests-credssp to get that.

Otherwise [https://github.com/jborean93/requests-credssp](https://github.com/jborean93/requests-credssp) shows the packages that must be installed for it to work and contains the minimum pyOpenSSL version that requests-credssp needs.

Thanks

Jordan
