rb-site manage shell error loading mysqldb module

141 views
Skip to first unread message

Gregory Rundlett

unread,
May 16, 2014, 3:43:52 PM5/16/14
to revie...@googlegroups.com
I'm unable to get a shell with rb-site.  I'm unsure of how this wraps Django, and what I could do to troubleshoot it, so any pointers are welcome.  I'm trying to get this setup on Red Hat Enterprise Linux Workstation release 6.5, and I've been successful so far, and even upgraded Review Board to version 1.7.25.  However, in all the effort to get Python 2.7 installed, I think I've run into the dependency hell situation.  Although the web application seems to be running fine, I'm concerned about the way my  rb-site manage shell/upgrade might be broken.

I can run rb-site manage /var/www/reviewboard.example.com help

But, when I 
rb-site manage /var/www/reviewboard.example.com shell
I get this error output 
Traceback (most recent call last):
  File "/usr/local/bin/rb-site", line 9, in <module>
    load_entry_point('ReviewBoard==1.7.25', 'console_scripts', 'rb-site')()
  File "/usr/local/lib/python2.7/site-packages/ReviewBoard-1.7.25-py2.7.egg/reviewboard/cmdline/rbsite.py", line 2055, in main
    command.run()
  File "/usr/local/lib/python2.7/site-packages/ReviewBoard-1.7.25-py2.7.egg/reviewboard/cmdline/rbsite.py", line 1972, in run
    site.run_manage_command(args[0], args[1:])
  File "/usr/local/lib/python2.7/site-packages/ReviewBoard-1.7.25-py2.7.egg/reviewboard/cmdline/rbsite.py", line 589, in run_manage_command
    execute_manager(reviewboard.settings, [__file__, cmd] + params)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.12-py2.7.egg/django/core/management/__init__.py", line 459, in execute_manager
    utility.execute()
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.12-py2.7.egg/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.12-py2.7.egg/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.12-py2.7.egg/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.12-py2.7.egg/django/core/management/base.py", line 371, in handle
    return self.handle_noargs(**options)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.12-py2.7.egg/django/core/management/commands/shell.py", line 45, in handle_noargs
    from django.db.models.loading import get_models
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.12-py2.7.egg/django/db/__init__.py", line 40, in <module>
    backend = load_backend(connection.settings_dict['ENGINE'])
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.12-py2.7.egg/django/db/__init__.py", line 34, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.12-py2.7.egg/django/db/utils.py", line 92, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.12-py2.7.egg/django/db/utils.py", line 24, in load_backend
    return import_module('.base', backend_name)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.12-py2.7.egg/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.12-py2.7.egg/django/db/backends/mysql/base.py", line 16, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

I searched around and figured out that because I'm on RHEL 6, that my Python2.7 environment in /usr/local/bin probably wasn't seeing the yum installed MySQL-python.  So, I used /usr/local/bin/easy_install-2.7 MySQL-python to make it available in /usr/local/lib but that gave me this output:

# /usr/local/bin/easy_install-2.7 MySQL-python
Searching for MySQL-python
Best match: MySQL-python 1.2.5
Processing MySQL-python-1.2.5.zip
Writing /tmp/easy_install-NGUKg7/MySQL-python-1.2.5/setup.cfg
Running MySQL-python-1.2.5/setup.py -q bdist_egg --dist-dir /tmp/easy_install-NGUKg7/MySQL-python-1.2.5/egg-dist-tmp-hpusEI
In file included from /usr/include/mysql/my_config.h:14,
                 from _mysql.c:44:
/usr/include/mysql/my_config_x86_64.h:1082:1: warning: "HAVE_WCSCOLL" redefined
In file included from /usr/local/include/python2.7/Python.h:8,
                 from _mysql.c:29:
/usr/local/include/python2.7/pyconfig.h:908:1: warning: this is the location of the previous definition
zip_safe flag not set; analyzing archive contents...
Adding MySQL-python 1.2.5 to easy-install.pth file

Installed /usr/local/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg
Processing dependencies for MySQL-python
Finished processing dependencies for MySQL-python

The  warning: "HAVE_WCSCOLL" redefined scares me into thinking I just broke my base system managed by yum; and I still can't run a shell.  Now I get 

[!] Unable to execute the manager command shell: cannot import name
    util

This all led me to check if I had multiple versions of rb-site.  Lo and behold, there are two.  I don't know whether my site is running off Python 2.6 or Python 2.7, but there is a /usr/bin/rb-site and also a /usr/local/bin/rb-site and the latter gets executed first because my $PATH lists /usr/local/bin before /usr/bin 

[root@codereview ~]# echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/ant/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

Now if I run /usr/bin/rb-site manage /var/www/reviewboard.example.com shell I do get an interactive console!

[root@codereview ~]# /usr/bin/rb-site manage /var/www/reviewboard.example.com shell
Python 2.6.6 (r266:84292, Nov 21 2013, 10:50:32) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)

I guess I should start over with a virtualenv setup, and possibly use RedHat Software Collections.  Starting over is a royal pain.

Can anyone confirm or deny which is the best approach to get this setup on Red Hat Enterprise Linux Workstation release 6.5

Thanks,

Greg

David Trowbridge

unread,
May 19, 2014, 5:23:32 PM5/19/14
to reviewboard
Greg,

This sounds suspiciously like you do have multiple versions of python in play.

In general, the easiest way (which isn't part of our documentation yet) to install Review Board on RHEL is to use the packages which are part of EPEL. Even without that, I wouldn't ever try to upgrade the installed version of python (if the distro comes with 2.7 or 2.6, then I'd just use that; otherwise, I'd use a newer distro).

-David


--
Get the Review Board Power Pack at http://www.reviewboard.org/powerpack/
---
Sign up for Review Board hosting at RBCommons: https://rbcommons.com/
---
Happy user? Let us know at http://www.reviewboard.org/users/
---
You received this message because you are subscribed to the Google Groups "reviewboard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages