# Python can't find a common python script that is in module\_utils when running modules that use it

**URL:** <https://forum.ansible.com/t/python-cant-find-a-common-python-script-that-is-in-module-utils-when-running-modules-that-use-it/23814>\
**Category:** Ansible Developer\
**Created:** [February 24, 2017, 10:00pm UTC](https://forum.ansible.com/t/python-cant-find-a-common-python-script-that-is-in-module-utils-when-running-modules-that-use-it/23814 "2017-02-24T22:00:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave\_Kasberg](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@Dave\_Kasberg](https://forum.ansible.com/u/Dave_Kasberg)\
**Post date:** [February 24, 2017, 10:00pm UTC](https://forum.ansible.com/t/python-cant-find-a-common-python-script-that-is-in-module-utils-when-running-modules-that-use-it/23814/1 "2017-02-24T22:00:15Z")

</div>

I’m developing several new network modules for Ansible 2.3. I have placed the common functions that are shared among these modules in a python script and put it in ./module\_utils/cnos/cnos.py. “cnos” is our operating system name, hence the name cnos.

The modules that use this library import it via “import cnos” , however when they run, I get the following error:

> [WARNING]: Removed unexpected internal key in module return: \_ansible\_parsed = False
> 
> An exception occurred during task execution. The full traceback is:
> 
> Traceback (most recent call last):
> 
> File “/tmp/ansible\_G7YHg\_/ansible\_module\_cnos\_command.py”, line 157, in
> 
> main()
> 
> File “/tmp/ansible\_G7YHg\_/ansible\_module\_cnos\_command.py”, line 131, in main
> 
> output = output + cnos.waitForDeviceResponse(“\n”, “\>”, 2, remote\_conn)
> 
> NameError: global name ‘cnos’ is not defined

This is rectified by setting the PYTHONPATH to this value: /usr/local/lib/python2.7/dist-packages/ansible-2.3.0-py2.7.egg/ansible/module\_utils

I am working from the development branch and after I ‘make’ it I install ansible via:

> python setup.py install

Will the requirement to set PYTHONPATH be eliminated when official RCs are created, or is there something I’m doing wrong here…

Thanks

---

<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:** [February 24, 2017, 10:08pm UTC](https://forum.ansible.com/t/python-cant-find-a-common-python-script-that-is-in-module-utils-when-running-modules-that-use-it/23814/2 "2017-02-24T22:08:05Z")

</div>

You probably want to follow the running from source instructions, to avoid having to install things while working on them. You can run everything directly from the git clone:

[http://docs.ansible.com/ansible/intro\_installation.html#running-from-source](http://docs.ansible.com/ansible/intro_installation.html#running-from-source)

---

<div class="post-metadata">

**Author:** ![Dave\_Kasberg](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@Dave\_Kasberg](https://forum.ansible.com/u/Dave_Kasberg)\
**Post date:** [February 27, 2017, 3:44pm UTC](https://forum.ansible.com/t/python-cant-find-a-common-python-script-that-is-in-module-utils-when-running-modules-that-use-it/23814/3 "2017-02-27T15:44:20Z")

</div>

Thanks for that. Now if I want to have my QA team test this with an installation, can you point me to the directions on how they would go about that? I scanned the documentation and it was’t obvious to me.

---

<div class="post-metadata">

**Author:** ![Dave\_Kasberg](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@Dave\_Kasberg](https://forum.ansible.com/u/Dave_Kasberg)\
**Post date:** [February 28, 2017, 3:58am UTC](https://forum.ansible.com/t/python-cant-find-a-common-python-script-that-is-in-module-utils-when-running-modules-that-use-it/23814/4 "2017-02-28T03:58:45Z")

</div>

I found the info on how to make debs and rpms. I tried to do a build with ‘make deb’, but ran into an issue that I’ll put in a separate post…
