# Ansible Python Module Error.

**URL:** <https://forum.ansible.com/t/ansible-python-module-error/28660>\
**Category:** Ansible Project\
**Created:** [September 27, 2018, 10:52am UTC](https://forum.ansible.com/t/ansible-python-module-error/28660 "2018-09-27T10:52:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saurabh](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@Saurabh](https://forum.ansible.com/u/Saurabh)\
**Post date:** [September 27, 2018, 10:52am UTC](https://forum.ansible.com/t/ansible-python-module-error/28660/1 "2018-09-27T10:52:40Z")

</div>

Hi All,

if i give os.path.dirname(os.path.abspath(os.path.realpath(ansible. **file** ))) command in python terminal will give me “/usr/lib/python2.7/site-packages/ansible”

but if same command i write in own ansible python module. it give this path :- **/tmp/ansible\_29S4ql/ansible\_modlib.zip/ansible**

Could you please help me for this issue ?

Regads  
Saurabh

---

<div class="post-metadata">

**Author:** ![Ankit2](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@Ankit2](https://forum.ansible.com/u/Ankit2)\
**Post date:** [September 27, 2018, 4:04pm UTC](https://forum.ansible.com/t/ansible-python-module-error/28660/2 "2018-09-27T16:04:05Z")

</div>

What is the issue then?

---

<div class="post-metadata">

**Author:** ![Saurabh](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@Saurabh](https://forum.ansible.com/u/Saurabh)\
**Post date:** [September 28, 2018, 4:42am UTC](https://forum.ansible.com/t/ansible-python-module-error/28660/3 "2018-09-28T04:42:44Z")

</div>

Issue is that, I want to get /usr/lib/python2.7/site-packages/ansible path. if i mention in ansible python module code this line os.path.dirname(os.path.abspath(os.path.realpath(ansible. **file** ))).

It’s not giving me actual path but it’s giving me /tmp/\* path example ( **/tmp/ansible\_29S4ql/ansible\_modlib.zip/ansible )**

**how can i achieve so that i can get** /usr/lib/python2.7/site-packages/ansible path dynamically depend on python 2.7 or python 3\* version.

Could you please help me for this.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [September 28, 2018, 2:10pm UTC](https://forum.ansible.com/t/ansible-python-module-error/28660/4 "2018-09-28T14:10:42Z")

</div>

Ansible modules should not attempt to import code from Ansible itself.

An ansible module has access to a custom built (stripped down) ansible package for importing things from `ansible.module_utils`
