# S3 problem ( ImportError: No module named hashlib )

**URL:** <https://forum.ansible.com/t/s3-problem-importerror-no-module-named-hashlib/13507>\
**Category:** Ansible Project\
**Created:** [September 19, 2013, 12:10pm UTC](https://forum.ansible.com/t/s3-problem-importerror-no-module-named-hashlib/13507 "2013-09-19T12:10:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_Goodliff](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@Steven\_Goodliff](https://forum.ansible.com/u/Steven_Goodliff)\
**Post date:** [September 19, 2013, 12:10pm UTC](https://forum.ansible.com/t/s3-problem-importerror-no-module-named-hashlib/13507/1 "2013-09-19T12:10:39Z")

</div>

Hi,

I’m running ansible 1.3 from git on RHEL5 and is all working great, I’m trying to get the s3 module up and running for some log archiving but when i try something like

tasks:

- name: GET OBJECT from S3  
local\_action: s3 bucket=sjgmedia object=/photos/locations/copenhagen/DSC\_0001.JPG dest=/tmp/DSC\_0001.pg overwrite=true

ansible-playbook s3test.yml -vv

PLAY [cobbler] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK: [GET OBJECT from S3] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
\<127.0.0.1\> REMOTE\_MODULE s3 bucket=sjgmedia object=/photos/locations/copenhagen/DSC\_0001.JPG dest=/tmp/DSC\_0001.pg overwrite=true  
failed: [cobbler] =\> {“failed”: true, “parsed”: false}  
invalid output was: Traceback (most recent call last):  
File “/home/sgoodliff/.ansible/tmp/ansible-1379592526.12-166004534605062/s3”, line 113, in ?  
import hashlib  
ImportError: No module named hashlib

FATAL: all hosts have already failed – aborting

I installed boto from git and lss3 works for example.

Any ideas ? I guess its a python 2.4 / 2.6 issue or the interaction between ansible and boto.

Thanks

Steve

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [September 19, 2013, 1:03pm UTC](https://forum.ansible.com/t/s3-problem-importerror-no-module-named-hashlib/13507/2 "2013-09-19T13:03:56Z")

</div>

Yes, hashlib is python 2.5+, so that is a bug. Could you open a github issue for this? Thanks!

---

<div class="post-metadata">

**Author:** ![Steven\_Goodliff](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@Steven\_Goodliff](https://forum.ansible.com/u/Steven_Goodliff)\
**Post date:** [September 19, 2013, 1:38pm UTC](https://forum.ansible.com/t/s3-problem-importerror-no-module-named-hashlib/13507/3 "2013-09-19T13:38:08Z")

</div>

Hi,

Issue #4174 raised

thanks

Steve

---

<div class="post-metadata">

**Author:** ![Steven\_Goodliff](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@Steven\_Goodliff](https://forum.ansible.com/u/Steven_Goodliff)\
**Post date:** [September 23, 2013, 11:04am UTC](https://forum.ansible.com/t/s3-problem-importerror-no-module-named-hashlib/13507/4 "2013-09-23T11:04:45Z")

</div>

Hello,

ansible/library/cloud/s3 has #!/usr/bin/python as the 1st line. setting it to #!/usr/bin/env python fixes it for me.

is that how it should be or am I going to run into more problems changing that ?

Thanks

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [September 23, 2013, 11:47am UTC](https://forum.ansible.com/t/s3-problem-importerror-no-module-named-hashlib/13507/5 "2013-09-23T11:47:04Z")

</div>

Hi Steven,

If you can please ask new questions in new threads that would be appreciated.

Meanwhile, the answer to your question is “ansible\_python\_interpreter”, which is covered in the early sections of the documentation.

(/usr/bin/env incorrectly assumes the executable is always named “python”, which is not actually true, because sometimes it’s named python26. More so, it relies on a user path and wrongly assumes the user account has the right python ahead in the path)

---

<div class="post-metadata">

**Author:** ![Steven\_Goodliff](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@Steven\_Goodliff](https://forum.ansible.com/u/Steven_Goodliff)\
**Post date:** [September 23, 2013, 12:52pm UTC](https://forum.ansible.com/t/s3-problem-importerror-no-module-named-hashlib/13507/6 "2013-09-23T12:52:05Z")

</div>

Hi,

I tried the setting ansible\_python\_interpreter in the playbook and it didnt help. I’ve also tried in the inventory file as below

cobbler ansible\_python\_interpreter=/usr/bin/python26

both gave exactly the same error as before.

So must be down to some oddity in my setup but if my workaround is incorrect im not sure where to look now or how to proceed.

I thought it was related question / answer hence the same thread.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [September 23, 2013, 5:26pm UTC](https://forum.ansible.com/t/s3-problem-importerror-no-module-named-hashlib/13507/7 "2013-09-23T17:26:50Z")

</div>

I’d have to see your playbook to make sure, but possibly you’re talking to a different host.

Since you mentioned ‘s3’, perhaps you are doing this as “local\_action” ?

---

<div class="post-metadata">

**Author:** ![Steven\_Goodliff](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@Steven\_Goodliff](https://forum.ansible.com/u/Steven_Goodliff)\
**Post date:** [September 24, 2013, 8:48am UTC](https://forum.ansible.com/t/s3-problem-importerror-no-module-named-hashlib/13507/8 "2013-09-24T08:48:13Z")

</div>

Hi,

Yep its a local action that just runs

tasks:

- name: GET OBJECT from S3  
local\_action: s3 bucket=sjgmedia object=/photos/locations/copenhagen/DSC\_0001.JPG dest=/tmp/DSC\_0001.pg overwrite=true mode=get

thanks again

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [September 25, 2013, 12:30am UTC](https://forum.ansible.com/t/s3-problem-importerror-no-module-named-hashlib/13507/9 "2013-09-25T00:30:58Z")

</div>

Hi Steven,

Since it’s local action this I think is a known issue where ansible\_python\_interpreter is not pulled from localhost for local action.

Can you see if it is set there and see if it helps?

localhost ansible\_python\_interpreter=/usr/bin/whatever

Thanks!

---

<div class="post-metadata">

**Author:** ![Steven\_Goodliff](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@Steven\_Goodliff](https://forum.ansible.com/u/Steven_Goodliff)\
**Post date:** [September 25, 2013, 2:51pm UTC](https://forum.ansible.com/t/s3-problem-importerror-no-module-named-hashlib/13507/10 "2013-09-25T14:51:46Z")

</div>

Hi,

Yeah thats sorted it out.

Thanks very much.

Steve
