# Circular dependency issue in release 1.4 ?

**URL:** <https://forum.ansible.com/t/circular-dependency-issue-in-release-1-4/13977>\
**Category:** Ansible Developer\
**Created:** [November 22, 2013, 7:44pm UTC](https://forum.ansible.com/t/circular-dependency-issue-in-release-1-4/13977 "2013-11-22T19:44:32Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mathieu\_Leduc-Hamel](https://avatars.discourse-cdn.com/v4/letter/m/4491bb/32.png) [@Mathieu\_Leduc-Hamel](https://forum.ansible.com/u/Mathieu_Leduc-Hamel)\
**Post date:** [November 22, 2013, 7:44pm UTC](https://forum.ansible.com/t/circular-dependency-issue-in-release-1-4/13977/1 "2013-11-22T19:44:32Z")

</div>

I’ve just upgrade my installation of ansible with the latest release and it seems there’s an issue with the callbacks module:

Considering the following directory structure:

ansible/  
callbacks.py  
utils/  
**init**.py

callbacks.py line 18:

import utils

utils/ **init**.py line 30:

from ansible.callbacks import display

This is just not possible since it take you to a circular dependency.

I’m not really sure what would be the best way to deal with that, probably splitting utils into multiple modules or removing code from **init**.py, i’m not exactly sure. Also i might not be the first one to raise this point, if it’s the case, i’m sorry about that 🙂

---

<div class="post-metadata">

**Author:** ![tannerjc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjc/32/985_2.png) [@tannerjc](https://forum.ansible.com/u/tannerjc)\
**Post date:** [November 22, 2013, 7:47pm UTC](https://forum.ansible.com/t/circular-dependency-issue-in-release-1-4/13977/2 "2013-11-22T19:47:38Z")

</div>

How was it installed and then upgraded?

---

<div class="post-metadata">

**Author:** ![Mathieu\_Leduc-Hamel](https://avatars.discourse-cdn.com/v4/letter/m/4491bb/32.png) [@Mathieu\_Leduc-Hamel](https://forum.ansible.com/u/Mathieu_Leduc-Hamel)\
**Post date:** [November 22, 2013, 8:02pm UTC](https://forum.ansible.com/t/circular-dependency-issue-in-release-1-4/13977/3 "2013-11-22T20:02:47Z")

</div>

using pip:

pip install ansible

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [November 22, 2013, 8:54pm UTC](https://forum.ansible.com/t/circular-dependency-issue-in-release-1-4/13977/4 "2013-11-22T20:54:27Z")

</div>

I imagine the world would be yelling us in greater quantity if callbacks weren’t working.

Please let us know steps to reproduce this problem and we can take a look, though I think it’s possible you have a mixed up install where you have “make installed” 1.3 or something and need to clean up after it, maybe?

---

<div class="post-metadata">

**Author:** ![Mathieu\_Leduc-Hamel](https://avatars.discourse-cdn.com/v4/letter/m/4491bb/32.png) [@Mathieu\_Leduc-Hamel](https://forum.ansible.com/u/Mathieu_Leduc-Hamel)\
**Post date:** [November 22, 2013, 9:35pm UTC](https://forum.ansible.com/t/circular-dependency-issue-in-release-1-4/13977/5 "2013-11-22T21:35:43Z")

</div>

That’s quite easy:

$ virtualenv test  
$ source test/bin/activate  
$ python

> > > from ansible import callbacks, utils

Traceback (most recent call last):  
File “”, line 1, in   
File “/Users/mlhamel/test/lib/python2.7/site-packages/ansible/callbacks.py”, line 18, in   
import utils  
File “/Users/mlhamel/test/lib/python2.7/site-packages/ansible/utils/ **init**.py”, line 30, in   
from ansible.callbacks import display  
ImportError: cannot import name display

I’m on OSX maverick

---

<div class="post-metadata">

**Author:** ![Mathieu\_Leduc-Hamel](https://avatars.discourse-cdn.com/v4/letter/m/4491bb/32.png) [@Mathieu\_Leduc-Hamel](https://forum.ansible.com/u/Mathieu_Leduc-Hamel)\
**Post date:** [November 22, 2013, 9:37pm UTC](https://forum.ansible.com/t/circular-dependency-issue-in-release-1-4/13977/6 "2013-11-22T21:37:36Z")

</div>

oh and i forget to mention an important step before running python:

$ pip install ansible

:-/

---

<div class="post-metadata">

**Author:** ![Mathieu\_Leduc-Hamel](https://avatars.discourse-cdn.com/v4/letter/m/4491bb/32.png) [@Mathieu\_Leduc-Hamel](https://forum.ansible.com/u/Mathieu_Leduc-Hamel)\
**Post date:** [November 23, 2013, 3:04pm UTC](https://forum.ansible.com/t/circular-dependency-issue-in-release-1-4/13977/7 "2013-11-23T15:04:05Z")

</div>

Let me know if you are able to reproduce, i’ll fill a bug report whenever you’re ready, i was able to reproduce also on Linux (Ubuntu and Arch) with and without --no-site-packages on the virtualenv

---

<div class="post-metadata">

**Author:** ![Tiziano\_Perrucci](https://avatars.discourse-cdn.com/v4/letter/t/ecc23a/32.png) [@Tiziano\_Perrucci](https://forum.ansible.com/u/Tiziano_Perrucci)\
**Post date:** [February 15, 2014, 6:48pm UTC](https://forum.ansible.com/t/circular-dependency-issue-in-release-1-4/13977/8 "2014-02-15T18:48:43Z")

</div>

I confirm the issue.  
Did anybody looked at it?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [February 15, 2014, 6:57pm UTC](https://forum.ansible.com/t/circular-dependency-issue-in-release-1-4/13977/9 "2014-02-15T18:57:32Z")

</div>

I have a very poor memory 4 months back, but I haven’t heard of reports of anything like this.

Everybody seems to be following the install instructions and doing fine.

Curious what’s different in your case, but also the latest is 1.4.4, not 1.4, so perhaps try a recent release.

---

<div class="post-metadata">

**Author:** ![Tiziano\_Perrucci](https://avatars.discourse-cdn.com/v4/letter/t/ecc23a/32.png) [@Tiziano\_Perrucci](https://forum.ansible.com/u/Tiziano_Perrucci)\
**Post date:** [February 15, 2014, 7:57pm UTC](https://forum.ansible.com/t/circular-dependency-issue-in-release-1-4/13977/10 "2014-02-15T19:57:28Z")

</div>

All the 1.4.\* releases has this issue, previous 1.3.\* doesnt.

It’s simple to reproduce:

> $ virtualenv p-env
> 
> New python executable in p-env/bin/python…
> 
> $ . p-env/bin/activate
> 
> $ pip install ansible==1.4.5
> 
> Downloading/unpacking ansible==1.4.5
> 
> …
> 
> $ pip freeze
> 
> Jinja2==2.7.2
> 
> MarkupSafe==0.18
> 
> PyYAML==3.10
> 
> ansible==1.4.5
> 
> ecdsa==0.10
> 
> httplib2==0.8
> 
> paramiko==1.12.2
> 
> pycrypto==2.6.1
> 
> wsgiref==0.1.2
> 
> $ python
> 
> Python 2.7.2 (default, Oct 11 2012, 20:14:37)
> 
> [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
> 
> Type “help”, “copyright”, “credits” or “license” for more information.
> 
> > > > from ansible import callbacks
> 
> Traceback (most recent call last):
> 
> File “”, line 1, in
> 
> File “/Users/tiziano/Development/Work-Startersquad/prudentia/p-env/lib/python2.7/site-packages/ansible/callbacks.py”, line 18, in
> 
> import utils
> 
> File “/Users/tiziano/Development/Work-Startersquad/prudentia/p-env/lib/python2.7/site-packages/ansible/utils/ **init**.py”, line 30, in
> 
> from ansible.callbacks import display
> 
> ImportError: cannot import name display

looks like callbacks depends from utils, and utils depends from callbacks

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [February 15, 2014, 8:26pm UTC](https://forum.ansible.com/t/circular-dependency-issue-in-release-1-4/13977/11 "2014-02-15T20:26:45Z")

</div>

Why are you trying to import callbacks explicitly?

Core ansible works which is why I am confused here.

– Michael

---

<div class="post-metadata">

**Author:** ![Tiziano\_Perrucci](https://avatars.discourse-cdn.com/v4/letter/t/ecc23a/32.png) [@Tiziano\_Perrucci](https://forum.ansible.com/u/Tiziano_Perrucci)\
**Post date:** [February 15, 2014, 8:31pm UTC](https://forum.ansible.com/t/circular-dependency-issue-in-release-1-4/13977/12 "2014-02-15T20:31:31Z")

</div>

I’m developing a tool that uses Ansible and I want to run a Playbook myself, something like:

stats = callbacks.AggregateStats()  
playbook\_cb = callbacks.PlaybookCallbacks(verbose=True)  
runner\_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=True)  
playbook = PlayBook(  
playbook=playbook\_file,  
inventory=inventory,  
remote\_user=remote\_user,  
remote\_pass=remote\_pass,  
transport=transport,  
extra\_vars=extra\_vars,  
only\_tags=only\_tags,  
callbacks=playbook\_cb,  
runner\_callbacks=runner\_cb,  
stats=stats  
)

similar at want ansible-playbook does.

Do you have any suggestion?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [February 15, 2014, 8:37pm UTC](https://forum.ansible.com/t/circular-dependency-issue-in-release-1-4/13977/13 "2014-02-15T20:37:03Z")

</div>

I’d look at the bin script in /bin and follow the same pattern of imports probably.

– Michael
