New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Carbon cache: no module named carbon.util #514

Open
amdei opened this Issue Jan 8, 2016 · 16 comments

Comments

Projects
None yet
@amdei

amdei commented Jan 8, 2016

Exactly the same issue as #276 .
Debian 8 x64, installed
carbon-0.9.15
graphite-web-0.9.15
to default locations using pip.

When I trying to run:
python /usr/local/bin/carbon-cache.py start

I got:
Traceback (most recent call last):
File "/usr/local/bin/carbon-cache.py", line 28, in
from carbon.util import run_twistd_plugin
ImportError: No module named carbon.util

@skolsuper

This comment has been minimized.

skolsuper commented Jan 11, 2016

+1

I have installed into a virtualenv at /opt/graphite/venv, after activating with source /opt/graphite/venv/bin/activate in the python shell I can import whisper no problem, but import carbon throws an ImportError

@skolsuper

This comment has been minimized.

skolsuper commented Jan 11, 2016

import twisted and import zope also work.

@skolsuper

This comment has been minimized.

skolsuper commented Jan 11, 2016

I changed the virtualenv to the installation folder as recommended in the docs. This is the output I get below when trying to import carbon, hopefully it will help diagnose the problem. Box is a fresh install of ubuntu14.04 with python 2.7, after pip install whisper carbon graphite-web

vagrant@carbon:~$ cd /opt/graphite/
vagrant@carbon:/opt/graphite$ source bin/activate
(graphite)vagrant@carbon:/opt/graphite$ pip freeze
carbon==0.9.15
graphite-web==0.9.15
Twisted==15.5.0
txAMQP==0.6.2
wheel==0.24.0
whisper==0.9.15
zope.interface==4.1.3
(graphite)vagrant@carbon:/opt/graphite$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import carbon
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named carbon
@asurak

This comment has been minimized.

asurak commented Jan 27, 2016

Exactly the same issue here. I rollbacked to 0.9.12 from Ubuntu 14.04 repo and had to manually remove twisted from pip, otherwise even 0.9.12 did not work.

@asurak

This comment has been minimized.

asurak commented Jan 27, 2016

My colleague tried to make a container for 0.9.15 and locked the version of twisted to 11.1.0 and then it worked well. Here is the container.

@damm

This comment has been minimized.

damm commented Feb 27, 2016

This is a mess; I found the util stuck in /opt/graphite/lib/python/site-packages/opt/graphite/lib/

There's also some twisted plugins in there as well.

@cahlbin

This comment has been minimized.

cahlbin commented Mar 5, 2016

+1

Using virtualenv seems to be the problem. I'm seeing the carbon.util module ending up in /opt/graphite/lib/python2.7/site-packages/opt/graphite/lib.

Not using virtual env works fine as then the util module ends up in /opt/graphite/lib/carbon/util.py (as expected by carbon-cache.py, in terms of relative path to itself at least)

(CentOS 7)

@mleinart

This comment has been minimized.

Member

mleinart commented Mar 5, 2016

Looks like this is graphite's default prefix (/opt/graphite) screwing things up again. Unsure what changed to break this - perhaps it never worked in the first place.
You should be able to pass in --install-lib to point to the virtualenv's site-packages dir as in the 'custom install' section of the docs:
http://graphite.readthedocs.org/en/latest/install-pip.html?highlight=pip#installing-carbon-in-a-custom-location

Unfortunately there doesn't appear to be a reliable way to get this directory programmatically on the commandline (see http://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory) though if you're installing with a virtual env at /opt/graphite/ this should work:

source /opt/graphite/bin/activate
pip install carbon --install-option="install-lib=/opt/graphite/lib"
@damm

This comment has been minimized.

damm commented Mar 6, 2016

@cahlbin I'm not sure that /opt/graphite/lib/carbon/util.py is the right location without virtualenv

carbon should be installed into the python site-packages? that's what seems right to me. I suspect it would fail either way

This was introduced in #219

@deniszh

This comment has been minimized.

Member

deniszh commented Mar 6, 2016

@cahlbin is right, by default it's installing in /opt/graphite and not in python site-packages

@damm

This comment has been minimized.

damm commented Mar 7, 2016

right and it should be installed into the site-packages; regardless of virtualenv or not.

As virtualenv is just an isolated python install? (i guess that's a good phrase) it has roughly the same directory layout as the distro's install.

@qiangyao

This comment has been minimized.

qiangyao commented Sep 19, 2016

damm commented on 27 Feb
This is a mess; I found the util stuck in /opt/graphite/lib/python/site-packages/opt/graphite/lib/
There's also some twisted plugins in there as well.

mv /opt/graphite/lib/python/site-packages/opt/graphite/lib/carbon /opt/graphite/lib/python/site-packages/
mv /opt/graphite/lib/python/site-packages/opt/graphite/lib/twisted/plugins/carbon_* /opt/graphite/lib/python/site-packages/twisted/plugins/carbon_*

@damm

This comment has been minimized.

damm commented Sep 19, 2016

exactly @qiangyao

@marcusdb

This comment has been minimized.

marcusdb commented Feb 15, 2017

cp -rv /usr/local/lib/python2.7/dist-packages/opt/graphite/lib/carbon /usr/local/bin/ && cp -rv /usr/local/lib/python2.7/dist-packages/opt/graphite/lib/twisted /usr/local/bin/

This fixed the issue for me
ubuntu 16 // python 2.7 // Twisted (11.1.0) // carbon (0.9.15)

@7heo

This comment has been minimized.

7heo commented Mar 23, 2017

qiangyao commented on Sep 19, 2016

damm commented on 27 Feb

This is a mess; I found the util stuck in /opt/graphite/lib/python/site-packages/opt/graphite/lib/
There's also some twisted plugins in there as well.

mv /opt/graphite/lib/python/site-packages/opt/graphite/lib/carbon /opt/graphite/lib/python/site-packages/
mv /opt/graphite/lib/python/site-packages/opt/graphite/lib/twisted/plugins/carbon_* /opt/graphite/lib/python/site-packages/twisted/plugins/carbon_*

That will work for installations located in /opt/graphite. For virtualenv installations, cd to your virtualenv and run:

$ mv lib/python2.7/site-packages/opt/graphite/lib/carbon lib/python2.7/site-packages/
$ mv lib/python2.7/site-packages/opt/graphite/lib/twisted/plugins/* lib/python2.7/site-packages/twisted/plugins/
$ mv lib/python2.7/site-packages/opt/graphite/webapp/graphite webapp
$ rmdir -p lib/python2.7/site-packages/opt/graphite/lib/twisted/plugins/
$ rmdir -p lib/python2.7/site-packages/opt/graphite/webapp

And carbon will work.

@quixoten

This comment has been minimized.

quixoten commented Sep 5, 2018

Just got burnt by this on Ubuntu 16.04 using virtualenv (works on 14.04). Used rsync to fix following the guidance above:

rsync -av /opt/graphite/lib/python2.7/site-packages/opt/graphite/ /opt/graphite && rm -rf /opt/graphite/lib/python2.7/site-packages/opt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment