12

I am following these instructions(https://www.digitalocean.com/community/tutorials/how-to-install-and-use-graphite-on-an-ubuntu-14-04-server) to install statsd and graphite, but am running into below stated problem. Seems like this is not a graphite issue but python issue. Does anybody know how to resolve this?

~/build > sudo service carbon-cache start
 * Starting Graphite backend daemon carbon-cache
Traceback (most recent call last):
  File "/usr/bin/carbon-cache", line 32, in <module>
    run_twistd_plugin(__file__)
  File "/usr/lib/python2.7/dist-packages/carbon/util.py", line 90, in run_twistd_plugin
    config.parseOptions(twistd_options)
  File "/usr/local/lib/python2.7/dist-packages/twisted/application/app.py", line 604, in parseOptions
    usage.Options.parseOptions(self, options)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/usage.py", line 269, in parseOptions
    raise UsageError("Unknown command: %s" % sub)
twisted.python.usage.UsageError: Unknown command: carbon-cache
admdrew
  • 3,790
  • 4
  • 27
  • 39
user2574872
  • 945
  • 2
  • 11
  • 23
  • thanks sorry for the bad formatting – user2574872 Jan 14 '15 at 20:02
  • This bug is documented here a little but still can not find the solution http://osdir.com/ml/ubuntu-bugs/2014-07/msg06664.html – user2574872 Jan 14 '15 at 20:02
  • What instructions are you following, and do they require Python 3? I did a quick search and saw instructions that referenced `python3.2`. – admdrew Jan 14 '15 at 20:02
  • I am using python 2.7 ..is there a way i can point it to python 3? – user2574872 Jan 14 '15 at 20:07
  • That's out of scope for this question, but [this answer](http://askubuntu.com/questions/440114/ubuntu-14-04-python-2-7-still-default-set-3-x-as-default/440126#440126) could help you point to python 3 (assuming it's installed). – admdrew Jan 14 '15 at 20:12
  • no since i am using python 2.7 i do not want to acutally switch .. but just wanted to check if i could point graphite to python 3 ( in case that was causing this error) .. in the instructions i do not see that i need to use python 3 though .. so i am assuming something else is wrong – user2574872 Jan 14 '15 at 20:27

2 Answers2

20

I was following the same instructions and encountered the same problem.

Moving or removing the /usr/local/lib/python2.7/dist-packages/twisted directory also resolved the issue for me.

You can use for example the following command to change the name of the problematic directory:

mv /usr/local/lib/python2.7/dist-packages/twisted /usr/local/lib/python2.7/dist-packages/twisted2

Then use sudo service carbon-cache start again

Background

I had the same issue on my Ubuntu 14.04 machine. Some investigation indicates that there are two virtually identical areas for twisted plugins on my machine.

/usr/local/lib/python2.7/dist-packages/twisted

and

/usr/lib/python2.7/dist-packages/twisted

I am not sure where these two areas originate from. Perhaps one comes with the distro and the other is created through a manual pip install twisted that I may have done at one time. I suspect that the /usr/local/lib/python2.7/dist-packages/ area gets populated with content when I install packages using pip. So this problem my eventually be attributed to users (e.g. me) installing twisted via pip and via the apt package system.

In any case, a diff through these areas showed that the carbon related files were installed into the /usr/lib/python2.7/dist-packages/ area. dpkg -L graphite-carbon also indicates that the package files go into the /usr/lib/python2.7/dist-packages/ area.

However, when the carbon start script is run is appears that /usr/local/lib/python2.7/dist-packages/twisted/plugins area is used leading to the plugin not being found.

I assume that this issue is related to the modules search path. As can be seen below the /usr/local/lib/python2.7/dist-packages/ comes before the /usr/lib/python2.7/dist-packages/ in my default path.

$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', 
 '/usr/lib/python2.7', 
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk', 
 '/usr/lib/python2.7/lib-old', 
 '/usr/lib/python2.7/lib-dynload', 
 '/usr/local/lib/python2.7/dist-packages', 
 '/usr/lib/python2.7/dist-packages', 
 '/usr/lib/python2.7/dist-packages/PILcompat', 
 '/usr/lib/python2.7/dist-packages/gtk-2.0', 
 '/usr/lib/pymodules/python2.7', 
 '/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
>>> 
Aldian
  • 2,592
  • 2
  • 27
  • 39
claws
  • 201
  • 1
  • 2
12

for some reason twisted was messing up something with graphite. read on the internet that manually removng twisted solves the problem. Tried it and it works now

just did

 sudo rm -rf /usr/local/lib/python2.7/dist-packages/twiste*
user2574872
  • 945
  • 2
  • 11
  • 23
  • 4
    This worked. However, remember kids, before doing an `rm -rf` from some user2574872 dude on the internet, you should check if this is what you truly want. – cgf Oct 21 '15 at 20:19
  • 1
    'pip uninstall twisted' did the thing for me, which incidently removes exactly these files.. – Jan Feb 22 '17 at 15:08