# Importing Between Modules

**URL:** <https://forum.ansible.com/t/importing-between-modules/24653>\
**Category:** Ansible Developer\
**Created:** [June 5, 2017, 9:20pm UTC](https://forum.ansible.com/t/importing-between-modules/24653 "2017-06-05T21:20:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Burwell](https://avatars.discourse-cdn.com/v4/letter/j/b77776/32.png) [@John\_Burwell](https://forum.ansible.com/u/John_Burwell)\
**Post date:** [June 5, 2017, 9:20pm UTC](https://forum.ansible.com/t/importing-between-modules/24653/1 "2017-06-05T21:20:22Z")

</div>

Hello,

I am creating a module for yaourt, a front end for the pacman package manager wrapper [1]. Since yaourt proxies all the syntax of pacman, I refactored the pacman module to expose all operations in a class, PacmanModule [2], which parameterizes the command name allowing pacman and the variety frontends to share the same code. However, the importing the PacmanModule class from yaourt.py fails with an “No module named ansible.modules.packaging.os.pacman” exists. Do I have namespace incorrect? Is there something about the way modules are loaded/executed that prevents cross module imports?

Thanks for your help,  
-John

[1]: [https://archlinux.fr/yaourt-en](https://archlinux.fr/yaourt-en)  
[2]: [https://gist.github.com/jburwell/064ba48d3c180641fc6b7f6d9c2dd381](https://gist.github.com/jburwell/064ba48d3c180641fc6b7f6d9c2dd381)

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 5, 2017, 9:24pm UTC](https://forum.ansible.com/t/importing-between-modules/24653/2 "2017-06-05T21:24:46Z")

</div>

Modules get copied to the target machine, they won't include other  
modules, so this will fail. Well, except maybe on localhost or require  
all machines to have Ansible installed.

What you can do is refactor both modules to put shared code under  
module\_utils, which does get copied when a module imports it.
