Creating Python daemon - 'module' object has no attribute 'DaemonContext'

The program that produces the error is apparently using a different module named daemon. Did you perhaps call the program itself, or another module in the same directory, daemon.py?

If so, that will shadow the installed daemon module.

The solution

Rename daemon.py (and delete the daemon.pyc file that Python will have created) and try again.

If you don't see anything shadowing daemon.py, make your application print daemon.__file__ and see where it is being imported from.


pip uninstall daemon
pip install python-daemon

I run on this proglem too. If I call print daemon.__file__ it prints /usr/local/lib/python2.6/dist-packages/daemon.pyc, which is right file in wrong place, meaning that I have installed packege wrong way.

I used command "sudo pip install daemon", which installs only daemon.py file. We should use commnd "sudo pip install python-daemon", which installs whole package. After that print daemon.__file__ prints /usr/local/lib/python2.6/dist-packages/daemon/__init__.pyc, meaning that I have installed python-daemon -package, not just one python file daemon.py.

Confusing, but it was my own fault.

Remember to call "sudo pip uninstall daemon" before giving right installing command sudo pip uninstall python-daemon".