I am configuring a graphite monitoring system. When following the tutorial on https://gist.github.com/surjikal/2777886 I ran into the following import error:
python /opt/graphite/bin/carbon-cache.py start
Traceback (most recent call last):
File "/opt/graphite/bin/carbon-cache.py", line 28, in <module>
from carbon.util import run_twistd_plugin
File "/opt/graphite/lib/carbon/util.py", line 21, in <module>
from twisted.scripts._twistd_unix import daemonize
ImportError: cannot import name daemonize
Googling around I found several possible solutions for this issue:
1) Remove the daemonize
imports from /opt/graphite/lib/carbon/util.py
(https://answers.launchpad.net/graphite/+question/239063):
from time import sleep, time
from twisted.python.util import initgroups
from twisted.scripts.twistd import runApp
# from twisted.scripts._twistd_unix import daemonize
# daemonize = daemonize # Backwards compatibility
2) Use Twisted 13.1.0 instead of a higher twisted version.
3) Install daemonize
via pip and import it directly (https://www.digitalocean.com/community/tutorials/installing-and-configuring-graphite-and-statsd-on-an-ubuntu-12-04-vps):
# from twisted.scripts._twistd_unix import daemonize
import daemonize
What is the most stable and proven solution for a twisted environment to fix this import issue?
Option (2) sounds like the best option to me - particularly if you can find some documentation from the Graphite team about Twisted 13.1 being a supported version of Twisted (they should document the supported versions of their dependencies).
With option (1) you're diverging your installation from upstream. This is eventually going to be an admin headache.
I'm pretty sure option (3) won't help. The daemonize
module is only related in that it has the same name and does vaguely the same thing. It is not a drop-in replacement, though.