Hi,

I am using mac. I can notice for different module it takes two path.
either it takes from '/Library/Python/2.7/site-packages or 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib

>>> import jinja2

>>> jinja2

<module 'jinja2' from 
'/Library/Python/2.7/site-packages/jinja2/__init__.pyc'>

>>> import json

>>> json

<module 'json' from 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.pyc'

if i am using any module form /Library/Python/2.7/site-packages in my 
module being used by playbook i am getting ImportError.


My sample module say just contains 2 lines only (to show you import error):

#!/usr/bin/env python2.7

import jinja2

ansible-playbook playbook.yml -v


PLAY [all] 
******************************************************************** 


GATHERING FACTS 
*************************************************************** 

ok: [jumper]


TASK: [Update apt cache] 
****************************************************** 

failed: [jumper] => {"failed": true, "parsed": false}

invalid output was: Traceback (most recent call last):

  File 
"/var/home/regress/.ansible/tmp/ansible-tmp-1402303699.01-180301714079799/test",
 
line 2, in <module>

    import jinja2

ImportError: No module named jinja2

FATAL: all hosts have already failed -- aborting

PLAY RECAP 
******************************************************************** 

           to retry, use: --limit @/Users/nitinkr/playbook.retry

jumper                     : ok=1    changed=0    unreachable=0    failed=1 
 


I am not getting any importError for modules inside 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib.

One more thing to notice:

from python console $path show to be

>>> import sys

>>> sys.path

['', '/Library/Python/2.7/site-packages/pip-1.5.4-py2.7.egg', 
'/Library/Python/2.7/site-packages', 
'/Users/nitinkr/Documents/PyEZ/py-junos-eznc/lib', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
 
'/Library/Python/2.7/site-packages']


but same code from module:

#!/usr/bin/env python2.7

import sys

import json

print json.dumps({

    "path" : sys.path

})

show $path as:

ok: [jumper] => {"path": 
["/var/home/regress/.ansible/tmp/ansible-tmp-1402303903.41-149497005219721", 
"/packages/mnt/py-base-i386/usr/lib/python27.zip", "/usr/lib/python2.7", 
"/usr/lib/python2.7/lib-dynaload", "/usr/lib/python2.7/plat-junos", 
"/usr/lib/python2.7/site-packages", "/opt/lib/python2.7", 
"/opt/lib/python2.7/lib-dynaload", "/opt/lib/python2.7/plat-junos", 
"/opt/lib/python2.7/site-packages", 
"/packages/mnt/py-base-i386/usr/lib/python2.7/lib-dynload"]}


why is this discrepancies. 

how to resolve my ImportError? I tried 
adding PATH=$PATH:/Library/Python/2.7/site-packages to ~/.profile but of no 
use.

Anticipating your reply soon as its blocking my work.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c4aed4a5-5b3f-4889-8be0-bb324df68fc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to