# Import module error: ansible.utils.display

**URL:** <https://forum.ansible.com/t/import-module-error-ansible-utils-display/29559>\
**Category:** Ansible Developer\
**Created:** [January 29, 2019, 9:18am UTC](https://forum.ansible.com/t/import-module-error-ansible-utils-display/29559 "2019-01-29T09:18:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Klychkov](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@Andrew\_Klychkov](https://forum.ansible.com/u/Andrew_Klychkov)\
**Post date:** [January 29, 2019, 9:18am UTC](https://forum.ansible.com/t/import-module-error-ansible-utils-display/29559/1 "2019-01-29T09:18:00Z")

</div>

Hi, all!  
I’m trying to import:  
117 from ansible.utils.display import Display

in my new module, placed in lib/ansible/modules/database/postgresql/

But during tests and execution the following error occurred:  
Sanity check using import with Python 2.7  
ERROR: Found 1 import issue(s) on python 2.7 which need to be resolved:  
ERROR: lib/ansible/modules/database/postgresql/postgresql\_ping.py:117:0: ImportError: No module named utils.display  
…  
Any ideas, why?

This module successfully imported by the same line in lib/ansible/utils/display.py.

I want to add it to display warnings in the shell.

Maybe there is better way to do this.

I’ll be grateful for any ideas, thank you!

---

<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:** [January 29, 2019, 2:38pm UTC](https://forum.ansible.com/t/import-module-error-ansible-utils-display/29559/2 "2019-01-29T14:38:36Z")

</div>

Modules cannot import things from outside of `ansible.module_utils`. As such you cannot use `Display` in a module.

In addition to that, a module may only output JSON at the end of the execution, via `module.fail_json` or `module.exit_json`

You can however use `module.warn` to send back warnings that will be displayed to the user.

---

<div class="post-metadata">

**Author:** ![Andrew\_Klychkov](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@Andrew\_Klychkov](https://forum.ansible.com/u/Andrew_Klychkov)\
**Post date:** [January 30, 2019, 6:42am UTC](https://forum.ansible.com/t/import-module-error-ansible-utils-display/29559/3 "2019-01-30T06:42:53Z")

</div>

Hello, module.warn() works great. Thank you!

вт, 29 янв. 2019 г. в 17:39, Matt Martz \<[matt@sivel.net](mailto:matt@sivel.net)\>:
