Symptoms: File is apparently being used:
File "/usr/lib/python2.7/dist-packages/salt/renderers/pyobjects.py", line 449, in render
exec final_template in _globals, _locals
File "<string>", line 6, in <module>
File "/usr/lib/python2.7/dist-packages/salt/utils/pyobjects.py", line 293, in __getattr__
raise AttributeError
Great. However when I go to /usr/lib/python2.7/dist-packages/salt/utils/pyobjects.py it isn't in that directory and none of its pyc's are there either:
ls /usr/lib/python2.7/dist-packages/salt/utils/py*
/usr/lib/python2.7/dist-packages/salt/utils/pydsl.py /usr/lib/python2.7/dist-packages/salt/utils/pydsl.pyc
Why is this happening? What am I missing about this -- I have tried searching and found nothing useful yet.
Update if this is any use:
$ python -v
>>> import salt.utils.pyobjects
# /usr/local/lib/python2.7/dist-packages/salt/utils/pyobjects.pyc matches /usr/local/lib/python2.7/dist-packages/salt/utils/pyobjects.py
import salt.utils.pyobjects # precompiled from /usr/local/lib/python2.7/dist-packages/salt/utils/pyobjects.pyc
1 Answer 1
The python -v verbose output you posted shows that the file is imported from a different location:
/usr/local/lib/python2.7/dist-packages/salt/utils/pyobjects.pyc
# ^^^^^
but you are looking in:
ls /usr/lib/python2.7/dist-packages/salt/utils/py*
# ^^^^
.pyc files store a filename in the bytecode, and the file must've been moved from /usr/lib to /usr/local/lib. So when a traceback is shown, the filename from the bytecode is still pointing to the old location.
You can force a re-compile (running with sudo or another means to gain write access) with:
python -m compileall -f /usr/local/lib/python2.7/dist-packages/salt
to produce .pyc files that store the new location.
.pycfile was moved elsewhere and that is now being imported, but the file recorded a full-path filename?. Runpython -vand trace all imports./usr/local/lib/python2.7/dist-packages/salt/utils/pyobjects.pycand/usr/local/lib/python2.7/dist-packages/salt/utils/pyobjects.pyexist according to the OS and have a modification time and can be read.