graphite-project / graphite-web

A highly scalable real-time graphing system
http://graphite.readthedocs.org/
Apache License 2.0
5.88k stars 1.26k forks source link

No Module Named Graphite [Q] #2767

Closed dishorned closed 1 year ago

dishorned commented 2 years ago

Hi Guys,

I tried to get help within the Discussions section, but with no luck yet. Hope someone can help me here.

I just copy/paste my question from the discussions section:

I want to set up a new, clean Debian VM and only install Graphite on it. I tried a lot of different szenarios and tutorials including installing it with pip or from source (cannot install it with the apt package manager, because graphite-web is not in the debian 11 repository), but nothing works.

But let's go a step back. I am using a fresh installed debian 11 VM, which is up to date, with no special software installed. For getting graphite up and running, I installed all the required dependencies showing up in the check-dependencies.py and additional to it, apache2.

After all dependencies are met, I installed carbon with requirements (including whisper) and graphite-web:

git clone https://github.com/graphite-project/carbon git clone https://github.com/graphite-project/graphite-web cd carbon pip install -r requirements.txt python3 setup.py install cd .. cd graphite-web python3 setup.py install

At this point, everything seems good. I want to use a mariadb instead of sqllite, so I changed that in the local_settings.py (/opt/graphite/webapp/graphite), which I copied from template. I also changed the secret-key and timezone.

Now the problem starts. Different tutorials show different methods to get the db up and running. One tutorial says, to set it up using the graphite-manage command, but my system cannot find the command. So I also tried the more common way from the official tutorial:

PYTHONPATH=$GRAPHITE_ROOT/webapp django-admin.py migrate --settings=graphite.settings

Here it says, that the django.admin.py command is not found, but python3-django is installed. A django-admin.py file exists in a different folder. Does something is missing?

I also tried another way to set it up with the manage.py script, but that is showing the same error, when I try to directly run the settings.py script. It always says ModuleNotFoundError: No module named graphite.

I also tried it with python 2.7, because that is recommanded in the requirements.txt, but with no luck. I don't want to use docker, because I am not a linux pro and first I want to learn a lot about the system itself and how to manually (from source etc) install software, dependencies and solve errors.

Help is very appreciated and I hope you guys now, what I am doing wrong or what is missing.

thanks a lot and best regards

deniszh commented 2 years ago

Here it says, that the django.admin.py command is not found, but python3-django is installed. A django-admin.py file exists in a different folder. Does something is missing?

You can provide full path to django-admin.py command, if needed:

cd /opt/graphite/webapp
PYTHONPATH=$GRAPHITE_ROOT/webapp /full/path/to/django-admin.py migrate --settings=graphite.settings

I also tried it with python 2.7, because that is recommanded in the requirements.txt, but with no luck. I don't want to use docker, because I am not a linux pro and first I want to learn a lot about the system itself and how to manually (from source etc) install software, dependencies and solve errors.

IMO you'll need to be linux pro to install and operate Graphite from source (because of vast knowledge needed), and for operating it through Docker you don't need to know anything except Docker.

dishorned commented 2 years ago

Hi deniszh, thanks for your fast answer. I already tried the full-path to the django-admin.py, but I get the same error: No Module named Graphite

Do you have any last hint for me, how I can solve the problem? Otherwise I will take your advice and try the docker-image.

best regards

deniszh commented 2 years ago

@dishorned : That's strange. Before it helped - see e.g. https://github.com/graphite-project/graphite-web/issues/1708 You just need to do cd /opt/graphite/webapp/ before

cd /opt/graphite/webapp/
PYTHONPATH=/opt/graphite/webapp django-admin.py migrate --settings=graphite.settings --run-syncdb
dishorned commented 2 years ago

Hi @deniszh, I totally overread that issue. Now I am a step further, but still getting errors. Did I forget to configure somthing? Also the mariadb database config seems to be in an incorret syntax, but I only uncomment the lines and changed the values.

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/django/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 325, in execute
    settings.INSTALLED_APPS
  File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 79, in __getattr__
    self._setup(name)
  File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/opt/graphite/webapp/graphite/settings.py", line 238, in <module>
    globals().update(import_module(SETTINGS_MODULE).__dict__)
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 786, in exec_module
  File "<frozen importlib._bootstrap_external>", line 923, in get_code
  File "<frozen importlib._bootstrap_external>", line 853, in source_to_code
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/opt/graphite/webapp/graphite/local_settings.py", line 249
    DATABASES = {
IndentationError: unexpected indent

Do you have any idee, what I need to do?

thanks and best regards

deniszh commented 2 years ago

That should be easy to fix, @dishorned. Check identation in /opt/graphite/webapp/graphite/local_settings.py It's Python, so, you should use consistend identation - only spaces or only tabs. Please check e.g. https://stackoverflow.com/questions/1024435/how-to-fix-python-indentation for details how to fix that.

dishorned commented 2 years ago

Hi @deniszh, thanks for your help. All the settings in the config file starts with the settings-name and while I deleted the # sign, I forgot to also delete the space. So in my case, the line with the database settings startet with a space, instead of the settings-name (DATABASESE = {). But with your help, the script worked.

The database could successfully be created. I also copied all the example-settings-files in /opt/graphite/conf and creating them without the .example ending, but I let it in default configuration.

Then I created a vhost file but now I always getting a forbidden-message from the apache web-server. Maybe you know, why that happend. I can show the vhost configuration, but I tried several different configurations because I don't know which WSGI or Path-Alias settings are correct for apache+debian+wsgi.

Hope you have an idea, the goal seems to be very close ;)

best regards

argrento commented 2 years ago

Same for me. It seems that the 'default' installation is no longer default. When I execute python3 setup.py install from the graphite-web folder, I see this:

reating /opt/graphite/lib/python3.8/site-packages/graphite
copying build/lib/graphite/util.py -> /opt/graphite/lib/python3.8/site-packages/graphite
creating /opt/graphite/lib/python3.8/site-packages/graphite/render
copying build/lib/graphite/render/hashing.py -> /opt/graphite/lib/python3.8/site-packages/graphite/render
copying build/lib/graphite/render/grammar_unsafe.py -> /opt/graphite/lib/python3.8/site-packages/graphite/render
copying build/lib/graphite/render/datalib.py -> /opt/graphite/lib/python3.8/site-packages/graphite/render
copying build/lib/graphite/render/evaluator.py -> /opt/graphite/lib/python3.8/site-packages/graphite/render
copying build/lib/graphite/render/views.py -> /opt/graphite/lib/python3.8/site-packages/graphite/render
copying build/lib/graphite/render/grammar.py -> /opt/graphite/lib/python3.8/site-packages/graphite/render
copying build/lib/graphite/render/__init__.py -> /opt/graphite/lib/python3.8/site-packages/graphite/render
copying build/lib/graphite/render/glyph.py -> /opt/graphite/lib/python3.8/site-packages/graphite/render
copying build/lib/graphite/render/functions.py -> /opt/graphite/lib/python3.8/site-packages/graphite/render

...

Solution: cp -r build/lib/graphite /opt/graphite/webapp

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

dishorned commented 1 year ago

Hey Guys, the problem is still no solved. Any has a hint?

Thanks and best regards

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.