# Python Module not working

**URL:** <https://forum.ansible.com/t/python-module-not-working/17633>\
**Category:** Ansible Project\
**Created:** [February 27, 2015, 8:12am UTC](https://forum.ansible.com/t/python-module-not-working/17633 "2015-02-27T08:12:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cali\_Ban](https://avatars.discourse-cdn.com/v4/letter/c/5e9695/32.png) [@Cali\_Ban](https://forum.ansible.com/u/Cali_Ban)\
**Post date:** [February 27, 2015, 8:12am UTC](https://forum.ansible.com/t/python-module-not-working/17633/1 "2015-02-27T08:12:42Z")

</div>

Hello,

while the example time module in the ansible documentation is working, i wrote a new simple test module, but this is not runnin`g`:

`  
import socket  
import json

hostname = str(socket.gethostname())  
print json.dumps({  
“name” : hostname  
})

`

**_hacking/test-module -m hacking/gethostname.py_**

This return something weird:

`

/home/.ansible\_module\_generated: Zeile 4: Syntaxfehler beim unerwarteten Wort `(' /home/.ansible_module_generated: Zeile 4: `hostname = str(socket.gethostname())’

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [March 4, 2015, 3:17pm UTC](https://forum.ansible.com/t/python-module-not-working/17633/2 "2015-03-04T15:17:29Z")

</div>

Try putting a shebang line in your module. Make the following be the first line of your file:

#!/usr/bin/python

From your description of the cursor, your module is being executed by the shell instead of python. (The program, “import” is what changes the cursor like that.)

-Toshio
