ImportError: No module named defaults with python27 SCL

Asked by Maxim

Hi everyone

I am new user to graphite and i don't know python.

My goal is to build CentOS rpms for graphite family. I also want to use python27 from RedHat(and now CentOS) Software collection. Using python from software collection is mandatory in my case.

Briefly: i am running graphite-web development server and once it got a request, it reports this message: ImportError: No module named defaults

The long story follows.
BACKGROUND
Software collections (SCL) is the way to have as many concurent versions of software as i want in CentOS . In my case i have standard python2.6 which is heavily used by centos packaging system and is hard to replace in production. With SCL i can use python33 or python27 for any single program i want. For example, when i build graphite-web, i am running command
scl enable python27 'python check-dependencies.py'; python binary is found via modified environment variables, and python2.7 will be default.

STORY
I built some rpms for python27 libraries which are required by carbon and graphite-web
I have python27-pithon-django for example, as well as whisper, carbon, uwsgi, twisted, etc
I was able to run carbon under python27 and it seems to work fine and accept data.
Then i faced with problems running graphite-web via uwsgi. Going deeper and deeper i aned up with a clean Centos 6.5 chrooted environment where i install my packages and building graphite-web from source.

I am using latest version available, 0.9.12. scl enable python27 'python check-dependencies.py' said i have no fatal problems.
Then i install graphite-web with

scl enable python27 'python setup.py install'

Here is my changes to config, i only set SECRET_KEY:
diff -u local_settings.py.example local_settings.py
--- local_settings.py.example 2013-08-22 22:36:04.000000000 +0400
+++ local_settings.py 2014-01-09 13:11:39.956498364 +0400
@@ -10,7 +10,7 @@
 # install. This key is used for salting of hashes used in auth tokens,
 # CRSF middleware, cookie storage, etc. This should be set identically among
 # instances if used behind a load balancer.
-#SECRET_KEY = 'UNSAFE_DEFAULT'
+SECRET_KEY = '3ufosjdfeu89r43ur9jrfldsjoigud9u'

 # In Django 1.5+ set this to the list of hosts your graphite instances is
 # accessible as. See:

Next, i am running devel server with

scl enable python27 '/opt/graphite/bin/run-graphite-devel-server.py --port 32770 /opt/graphite'

And here is the output after one request sent

Running Graphite from /opt/graphite under django development server

/opt/rh/python27/root/usr/bin/django-admin runserver --pythonpath /opt/graphite/webapp --settings graphite.settings 0.0.0.0:32770
Validating models...

0 errors found
January 09, 2014 - 03:12:01
Django version 1.6.1, using settings 'graphite.settings'
Starting development server at http://0.0.0.0:32770/
Quit the server with CONTROL-C.
 Traceback (most recent call last):
  File "/opt/rh/python27/root/usr/lib64/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 206, in __call__
    response = self.get_response(request)
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 196, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 234, in handle_uncaught_exception
    if resolver.urlconf_module is None:
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/core/urlresolvers.py", line 341, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/opt/graphite/webapp/graphite/urls.py", line 15, in <module>
    from django.conf.urls.defaults import *
ImportError: No module named defaults
[09/Jan/2014 03:12:04] "GET / HTTP/1.0" 500 59
Traceback (most recent call last):
  File "/opt/rh/python27/root/usr/lib64/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 206, in __call__
    response = self.get_response(request)
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 196, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 234, in handle_uncaught_exception
    if resolver.urlconf_module is None:
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/core/urlresolvers.py", line 341, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/opt/graphite/webapp/graphite/urls.py", line 15, in <module>
    from django.conf.urls.defaults import *
ImportError: No module named defaults

And now i have no idea where to look information on how to handle this problem.

Question information

Language:
English Edit question
Status:
Solved
For:
Graphite Edit question
Assignee:
No assignee Edit question
Solved by:
Maxim
Solved:
Last query:
Last reply:
Revision history for this message
Maxim (monk-mail) said :
#1

I also created a database strucrute like this

cd /opt/graphite/webapp/graphite && scl enable python27 'python manage.py syncdb'
Creating tables ...
Creating table account_profile
Creating table account_variable
Creating table account_view
Creating table account_window
Creating table account_mygraph
Creating table dashboard_dashboard_owners
Creating table dashboard_dashboard
Creating table events_event
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_session
Creating table django_admin_log
Creating table django_content_type
Creating table tagging_tag
Creating table tagging_taggeditem

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'root'):
Email address:
Password:
Password (again):
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)

Revision history for this message
Maxim (monk-mail) said :
#2

And here is my versions

# yum list installed 'python27*' | awk '{print $1,$2}'
Installed Packages
python27-build.x86_64 1-10.el6.centos.alt
python27-py2cairo.x86_64 1.10.0-3.el6
python27-python.x86_64 2.7.5-7.el6.centos.alt
python27-python-carbon.noarch 0.9.12-3
python27-python-daemonize.x86_64 2.2.1-1.el6
python27-python-django.x86_64 1.6.1-1.el6
python27-python-django-tagging.x86_64 0.3.1-1.el6
python27-python-libs.x86_64 2.7.5-7.el6.centos.alt
python27-python-twisted.x86_64 13.2.0-1.el6
python27-python-whisper.noarch 0.9.12-2
python27-runtime.x86_64 1-10.el6.centos.alt

Revision history for this message
Maxim (monk-mail) said :
#3

Trying to build from git - and it works

# yum list installed 'python27*' | awk '{print $1,$2}'
Installed Packages
python27-build.x86_64 1-10.el6.centos.alt
python27-py2cairo.x86_64 1.10.0-3.el6
python27-pyparsing.noarch 2.0.1-1.el6
python27-python.x86_64 2.7.5-7.el6.centos.alt
python27-python-carbon.noarch 0.9.12-3
python27-python-daemonize.x86_64 2.2.1-1.el6
python27-python-django.x86_64 1.6.1-1.el6
python27-python-django-tagging.x86_64 0.3.1-1.el6
python27-python-libs.x86_64 2.7.5-7.el6.centos.alt
python27-python-twisted.x86_64 13.2.0-1.el6
python27-python-whisper.noarch 0.9.12-2
python27-python-zope-interface.x86_64 4.0.5-1
python27-pytz.noarch 2013.8-1.el6
python27-runtime.x86_64 1-10.el6.centos.alt

# scl enable python27 'python check-dependencies.py'
[OPTIONAL] Unable to import the 'memcache' module, do you have python-memcached installed for python 2.7.5? This feature is not required but greatly improves performance.
[OPTIONAL] Unable to import the 'ldap' module, do you have python-ldap installed for python 2.7.5? Without python-ldap, you will not be able to use LDAP authentication in the graphite webapp.
[OPTIONAL] Unable to import the 'txamqp' module, this is required if you want to use AMQP as an input to Carbon. Note that txamqp requires python 2.5 or greater.
[OPTIONAL] Unable to import the 'python-rrdtool' module, this is required for reading RRD.
[OPTIONAL] Unable to import 'cylowess', do you have cylowess installed for python 2.7.5? This allows for faster lowess processing (locallly weighted scatterplot smoothing) than the standard version, espcially for large datasets. You can install from here: https://github.com/livingsocial/cylowess
4 optional dependencies not met. Please consider the optional items before proceeding.
All necessary dependencies are met.

scl enable python27 'python setup.py install '

<many successful messages here>

sed "/#SECRET_KEY/ aSECRET_KEY\='fhkyhuifryifdsfs'" /opt/graphite/webapp/graphite/local_settings.py.example > /opt/graphite/webapp/graphite/local_settings.py

cd /root/graphite-web/webapp/ && scl enable python27 'python manage.py syncdb'
Could not import graphite.local_settings, using defaults!
/root/graphite-web/webapp/graphite/settings.py:215: UserWarning: SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security
  warn('SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security')
Creating tables ...
Creating table account_profile
Creating table account_variable
Creating table account_view
Creating table account_window
Creating table account_mygraph
Creating table dashboard_dashboard_owners
Creating table dashboard_dashboard
Creating table events_event
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_session
Creating table django_admin_log
Creating table django_content_type
Creating table tagging_tag
Creating table tagging_taggeditem

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'root'):
Email address:
Password:
Password (again):
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)

scl enable python27 '/opt/graphite/bin/run-graphite-devel-server.py --port 32770 /opt/graphite'
Running Graphite from /opt/graphite under django development server

/opt/rh/python27/root/usr/bin/django-admin runserver --pythonpath /opt/graphite/webapp --settings graphite.settings 0.0.0.0:32770
Validating models...

0 errors found
January 09, 2014 - 06:21:21
Django version 1.6.1, using settings 'graphite.settings'
Starting development server at http://0.0.0.0:32770/
Quit the server with CONTROL-C.
[09/Jan/2014 06:21:27] "GET / HTTP/1.0" 200 542
[09/Jan/2014 06:21:27] "GET /browser/header/ HTTP/1.0" 200 1030
[09/Jan/2014 06:21:27] "GET /composer/? HTTP/1.0" 200 1622
[09/Jan/2014 06:21:27] "GET /content/img/carbon-fiber.png HTTP/1.0" 200 3756
[09/Jan/2014 06:21:27] "GET /content/js/ext/adapter/ext/ext-base.js HTTP/1.0" 200 10591
[09/Jan/2014 06:21:27] "GET /content/js/ext/ext-all.js HTTP/1.0" 200 198538
[09/Jan/2014 06:21:27] "GET /content/js/completer.js HTTP/1.0" 200 1200
[09/Jan/2014 06:21:27] "GET /content/js/composer.js HTTP/1.0" 200 4893
[09/Jan/2014 06:21:27] "GET /content/js/browser.js HTTP/1.0" 200 5388
[09/Jan/2014 06:21:27] "GET /content/js/composer_widgets.js HTTP/1.0" 200 25148
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/css/ext-all.css HTTP/1.0" 200 75921
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/tabs/tab-strip-bg.gif HTTP/1.0" 200 172
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/s.gif HTTP/1.0" 200 64
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/tree/folder.gif HTTP/1.0" 200 394
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/tree/elbow-plus.gif HTTP/1.0" 200 230
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/layout/mini-left.gif HTTP/1.0" 200 147
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/tree/elbow-end-plus.gif HTTP/1.0" 200 227
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/tabs/tabs-sprite.gif HTTP/1.0" 200 1644
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/window/left-corners.png HTTP/1.0" 200 230
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/window/right-corners.png HTTP/1.0" 200 286
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/panel/tool-sprites.gif HTTP/1.0" 200 5324
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/toolbar/bg.gif HTTP/1.0" 200 266
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/window/top-bottom.png HTTP/1.0" 200 211
[09/Jan/2014 06:21:28] "GET /content/img/updateGraph.gif HTTP/1.0" 200 385
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/window/left-right.png HTTP/1.0" 200 178
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/grid/grid-blue-split.gif HTTP/1.0" 200 82
[09/Jan/2014 06:21:28] "GET /content/img/calBt.gif HTTP/1.0" 200 1488
[09/Jan/2014 06:21:28] "GET /content/img/arrow1.gif HTTP/1.0" 200 619
[09/Jan/2014 06:21:28] "GET /content/img/link.png HTTP/1.0" 200 1296
[09/Jan/2014 06:21:28] "GET /content/img/line_chart.png HTTP/1.0" 200 1839
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/button/arrow.gif HTTP/1.0" 200 119
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/button/btn.gif HTTP/1.0" 200 4353
[09/Jan/2014 06:21:28] "GET /render HTTP/1.0" 500 863
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/sizer/s-handle.gif HTTP/1.0" 200 628
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/sizer/e-handle.gif HTTP/1.0" 200 914
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/sizer/se-handle.gif HTTP/1.0" 200 177
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/sizer/ne-handle.gif HTTP/1.0" 200 177
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/sizer/nw-handle.gif HTTP/1.0" 200 182
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/sizer/sw-handle.gif HTTP/1.0" 200 177
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/shadow.png HTTP/1.0" 200 366
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/shadow-lr.png HTTP/1.0" 200 167
[09/Jan/2014 06:21:28] "GET /content/js/ext/resources/images/default/shadow-c.png HTTP/1.0" 200 148
[09/Jan/2014 06:21:28] "GET /render/?width=586&height=308&_salt=1389270088.677 HTTP/1.0" 500 863