graphite-project / graphite-web

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

[Q]ImportError: No module named django.conf #2700

Closed Linuxmaker closed 3 years ago

Linuxmaker commented 3 years ago

Hi,

I installed Graphite on Debian 10 in addition to Icinga2. However, I only get a 503 error in the web browser. This is the reason for this

[Wed May 05 11:36:47.515673 2021] [wsgi:error] [pid 22706] mod_wsgi (pid=22706): Failed to exec Python script file '/opt/graphite/conf/graphite.wsgi'.
[Wed May 05 11:36:47.515695 2021] [wsgi:error] [pid 22706] mod_wsgi (pid=22706): Exception occurred processing WSGI script '/opt/graphite/conf/graphite.wsgi'.
[Wed May 05 11:36:47.515706 2021] [wsgi:error] [pid 22706] Traceback (most recent call last):
[Wed May 05 11:36:47.515719 2021] [wsgi:error] [pid 22706]   File "/opt/graphite/conf/graphite.wsgi", line 7, in <module>
[Wed May 05 11:36:47.515756 2021] [wsgi:error] [pid 22706]     from graphite.wsgi import application
[Wed May 05 11:36:47.515762 2021] [wsgi:error] [pid 22706]   File "/opt/graphite/webapp/graphite/wsgi.py", line 12, in <module>
[Wed May 05 11:36:47.515783 2021] [wsgi:error] [pid 22706]     from django.conf import settings
[Wed May 05 11:36:47.515794 2021] [wsgi:error] [pid 22706] ImportError: No module named django.conf

I proceeded as follows during the installation:

apt install python3-dev libffi-dev python3-cairo-dev python-scandir apache2 libapache2-mod-wsgi python3-pip gcc
pip3 install --upgrade pip
pip install --no-binary=:all: https ://github.com/graphite-project/whisper/tarball/master
pip install --no-binary=:all: https ://github.com/graphite-project/carbon/tarball/master
pip install --no-binary=:all: https ://github.com/graphite-project/graphite-web/tarball/master
ln -s /opt/graphite/lib/carbon-1.2.0-py3.7.egg-info /usr/lib/python3/dist-packages/
ln -s /opt/graphite/webapp/graphite_web-1.2.0-py3.7.egg-info /usr/lib/python3/dist-packages/
PYTHONPATH=/opt/graphite/webapp django-admin.py migrate --settings=graphite.settings --run-syncdb
PYTHONPATH=/opt/graphite/webapp django-admin.py collectstatic --noinput --settings=graphite.settings
PYTHONPATH=/opt/graphite/webapp django-admin.py check --settings=graphite.settings
chown www-data:root /opt/graphite/storage/
chown www-data:www-data /opt/graphite/storage/graphite.db
chown -Rf www-data:root /opt/graphite/storage/log
systemctl enable carbon-cache.service
systemctl start carbon-cache.service

How I can solve it, so django.conf will be founded?

Best regards Andreas

deniszh commented 3 years ago

Hi @Linuxmaker ,

Did you install dependencies for graphite-web with pip3 install -r requirements.txt ?

deniszh commented 3 years ago

Also please show your webserver config for graphite-web

Linuxmaker commented 3 years ago

Did you install dependencies for graphite-web with pip3 install -r requirements.txt ?

I didn't use this command like that. I just ran the commands above. What should the content of the requirements.txt file be? I do not know this file.

deniszh commented 3 years ago

It's in the repo - https://github.com/graphite-project/graphite-web/blob/master/requirements.txt

deniszh commented 3 years ago

I also see another issue - you're installing e.g. libapache2-mod-wsgi which is for python2, then you set up everything for python3 which is looks fishy. So, please show your webserver config

Linuxmaker commented 3 years ago

Also please show your webserver config for graphite-web

That's my config file for the virtual host at Apache2: `<IfModule !wsgi_module.c> LoadModule wsgi_module modules/mod_wsgi.so

WSGISocketPrefix /var/run/wsgi

<VirtualHost 192.168.1.243:80> ServerName graphing.example.tld ServerAdmin hostmaster@example.tld DocumentRoot "/opt/graphite/webapp" ErrorLog /var/log/carbon/graphite-error.log CustomLog /var/log/carbon/graphite-access.log common

    WSGIDaemonProcess graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120
    WSGIProcessGroup graphite
    WSGIApplicationGroup %{GLOBAL}
    WSGIImportScript /opt/graphite/conf/graphite.wsgi process-group=graphite application-group=%{GLOBAL}

    WSGIScriptAlias / /opt/graphite/conf/graphite.wsgi

    Alias /static/ /opt/graphite/static/

    Alias /media/ "@DJANGO_ROOT@/contrib/admin/media/"

    <Directory /opt/graphite/conf/>
            <IfVersion < 2.4>
                    Order deny,allow
                    Allow from all
            </IfVersion>
            <IfVersion >= 2.4>
                    Require all granted
            </IfVersion>
    </Directory>
    <Directory /opt/graphite/static>
            Require all granted
    </Directory>

`

Linuxmaker commented 3 years ago

I also see another issue - you're installing e.g. libapache2-mod-wsgi which is for python2, then you set up everything for python3 which is looks fishy. So, please show your webserver config I think so right away. But existing HowTos for the installation of Graphite/Grafana in Icinga2 are partly different from each other. Do I need the Apache module libapache2-mod-wsgi if I should use "/opt/graphite/conf/graphite.wsgi"? Or which module I have to install for python3?

Linuxmaker commented 3 years ago

Now I have executed your command regarding the dependencies and I get these messages:

# pip3 install -r requirements.txt
Collecting whisper
  Cloning git://github.com/graphite-project/whisper.git to /tmp/pip-install-u1oew444/whisper_e043dbce7c294f7298b579e0fdbce48c
  Running command git clone -q git://github.com/graphite-project/whisper.git /tmp/pip-install-u1oew444/whisper_e043dbce7c294f7298b579e0fdbce48c
Requirement already satisfied: Django<3.1,>=1.8 in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 40)) (3.0.14)
Collecting python-memcached==1.58
  Downloading python-memcached-1.58.tar.gz (30 kB)
Collecting txAMQP==0.8
  Downloading txAMQP-0.8.0.tar.gz (39 kB)
Collecting django-tagging==0.4.6
  Downloading django_tagging-0.4.6-py2.py3-none-any.whl (35 kB)
Collecting gunicorn
  Downloading gunicorn-20.1.0-py3-none-any.whl (79 kB)
     |████████████████████████████████| 79 kB 2.1 MB/s 
Requirement already satisfied: pytz in /usr/lib/python3/dist-packages (from -r requirements.txt (line 45)) (2019.1)
Requirement already satisfied: pyparsing>=2.3.0 in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 46)) (2.4.7)
Requirement already satisfied: cairocffi in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 47)) (1.2.0)
Collecting whitenoise==4.1.4
  Downloading whitenoise-4.1.4-py2.py3-none-any.whl (20 kB)
Requirement already satisfied: scandir in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 52)) (1.10.0)
Requirement already satisfied: urllib3 in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 53)) (1.26.4)
Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 54)) (1.15.0)
Requirement already satisfied: Twisted in /usr/local/lib/python3.7/dist-packages (from txAMQP==0.8->-r requirements.txt (line 42)) (21.2.0)
Requirement already satisfied: asgiref~=3.2 in /usr/local/lib/python3.7/dist-packages (from Django<3.1,>=1.8->-r requirements.txt (line 40)) (3.3.4)
Requirement already satisfied: sqlparse>=0.2.2 in /usr/local/lib/python3.7/dist-packages (from Django<3.1,>=1.8->-r requirements.txt (line 40)) (0.4.1)
Requirement already satisfied: typing-extensions in /usr/local/lib/python3.7/dist-packages (from asgiref~=3.2->Django<3.1,>=1.8->-r requirements.txt (line 40)) (3.10.0.0)
Requirement already satisfied: setuptools>=3.0 in /usr/local/lib/python3.7/dist-packages (from gunicorn->-r requirements.txt (line 44)) (56.0.0)
Requirement already satisfied: cffi>=1.1.0 in /usr/local/lib/python3.7/dist-packages (from cairocffi->-r requirements.txt (line 47)) (1.14.5)
Requirement already satisfied: pycparser in /usr/local/lib/python3.7/dist-packages (from cffi>=1.1.0->cairocffi->-r requirements.txt (line 47)) (2.20)
Requirement already satisfied: incremental>=16.10.1 in /usr/local/lib/python3.7/dist-packages (from Twisted->txAMQP==0.8->-r requirements.txt (line 42)) (21.3.0)
Requirement already satisfied: Automat>=0.8.0 in /usr/local/lib/python3.7/dist-packages (from Twisted->txAMQP==0.8->-r requirements.txt (line 42)) (20.2.0)
Requirement already satisfied: zope.interface>=4.4.2 in /usr/local/lib/python3.7/dist-packages (from Twisted->txAMQP==0.8->-r requirements.txt (line 42)) (5.4.0)
Requirement already satisfied: hyperlink>=17.1.1 in /usr/local/lib/python3.7/dist-packages (from Twisted->txAMQP==0.8->-r requirements.txt (line 42)) (21.0.0)
Requirement already satisfied: constantly>=15.1 in /usr/local/lib/python3.7/dist-packages (from Twisted->txAMQP==0.8->-r requirements.txt (line 42)) (15.1.0)
Requirement already satisfied: attrs>=19.2.0 in /usr/local/lib/python3.7/dist-packages (from Twisted->txAMQP==0.8->-r requirements.txt (line 42)) (20.3.0)
Requirement already satisfied: idna>=2.5 in /usr/lib/python3/dist-packages (from hyperlink>=17.1.1->Twisted->txAMQP==0.8->-r requirements.txt (line 42)) (2.6)
Building wheels for collected packages: python-memcached, txAMQP
  Building wheel for python-memcached (setup.py) ... done
  Created wheel for python-memcached: filename=python_memcached-1.58-py2.py3-none-any.whl size=14670 sha256=ab1104aa4cd0d58194d6a50bbfe4f3a8780db97a9cbf8e3cdfcf38af719041fe
  Stored in directory: /root/.cache/pip/wheels/19/10/9b/bd220cf2a23e25d5a307e4de83025b8ed352061d75e1655336
  Building wheel for txAMQP (setup.py) ... done
  Created wheel for txAMQP: filename=txAMQP-0.8.0-py3-none-any.whl size=59929 sha256=ad95b8aeed17e6b4aef92de533a18d3b70e35900aba32aa745e8374417d8102b
  Stored in directory: /root/.cache/pip/wheels/49/c7/6b/717fbd356c947055ad809de40c91983ee87f9d11e6f1b2853c
Successfully built python-memcached txAMQP
Installing collected packages: whitenoise, txAMQP, python-memcached, gunicorn, django-tagging
  Attempting uninstall: txAMQP
    Found existing installation: txAMQP 0.8.2
    Uninstalling txAMQP-0.8.2:
      Successfully uninstalled txAMQP-0.8.2
  Attempting uninstall: django-tagging
    Found existing installation: django-tagging 0.4.3
    Uninstalling django-tagging-0.4.3:
      Successfully uninstalled django-tagging-0.4.3
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
graphite-web 1.2.0 requires django-tagging==0.4.3, but you have django-tagging 0.4.6 which is incompatible.
Successfully installed django-tagging-0.4.6 gunicorn-20.1.0 python-memcached-1.58 txAMQP-0.8.0 whitenoise-4.1.4

I would uninstall "django-tagging 0.4.6" and install manually "django-tagging==0.4.3", but I don't know how it runs at python.

deniszh commented 3 years ago

@Linuxmaker : First, you need to decide which python are you going to run. Currently your Apache WSGI module running using Python 2, but half of your commands using Pythion 3. That's not going to work. If you want python2 you need to adapt commands above with python2

stale[bot] commented 3 years 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.