Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying to install OpenStack Dashboard following this guide from git: http://wiki.openstack.org/OpenStackDashboard

But when I run this command to sync database:

$ tools/with_venv.sh openstack-dashboard/manage.py syncdb

It returns that:

File "/home/user1/horizon/.venv/local/lib/python2.7/sitepackages/django/db/backends/mysql>    /base.py", line 14, in <module>    
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

I installed package "python-mysqldb" several times, but it's still raised this error. When I run:

>>> import MySQLdb

in python interpreter, it's fine!

And I tried to install through easy_install, but the MySQL-python is installed:

$ sudo easy_install MySQL-python

Searching for MySQL-python

Best match: MySQL-python 1.2.3 MySQL-python 1.2.3 is already the active version in easy-install.pth

Using /usr/lib/pymodules/python2.7

Processing dependencies for MySQL-python

Finished processing dependencies for MySQL-python

Here are the content of tools/with_venv.sh

#!/bin/bash
TOOLS=`dirname $0`
VENV=$TOOLS/../.venv
source $VENV/bin/activate && $@

When I run: tools/with_venv.sh it returns nothing.

What's wrong in my case?

share|improve this question
1  
Seems like your virtualenv was run with --no-site-packages try running it without this arguments OR install mysqldb from within the virtualenv. i.e. easy_install MySQL-python –  sagarchalise Feb 27 '12 at 10:39
    
could you paste the content of tools/with_venv.sh ? –  sagarchalise Feb 27 '12 at 15:07

2 Answers 2

With virtualenv, you have your own environment specifically for that application. If you use --no-site-packages, it won't use system modules installed beyond the standard library.

The solution is to activate the virtual environment and install them there. Try something like this:

cd (project directory)
source bin/activate
easy_install MySQL-python

In doing so, you will install MySQLdb inside that project's own virtual environment, and it will be separate from the system-wide installation. The advantage of virtualenv is that it lets you keep multiple versions of software contained exactly where you need them.

share|improve this answer
    
Yes I done all those commands but you can see in my post. It announces that MySQL-python is active, but it is in the system-wide installation. I understand what you means but I can not install MySQL-python in the virtual environment. –  neo0 Feb 28 '12 at 2:38
    
When you run the source bin/activate script, does it change your prompt to say (project name) before it? –  Ken Feb 28 '12 at 2:42
    
In my case I run '$ source .venv/bin/activate' but it only return s '(.venv)' then nothing happen. –  neo0 Feb 28 '12 at 2:58
    
My guess is something is wrong with the virtual environment itself. Or maybe you're using an unusual shell? –  Ken Feb 29 '12 at 13:28
up vote 0 down vote accepted

I asked this question in launchpad too. Thank God they help me solve this problem. https://answers.launchpad.net/horizon/+question/189051

By running this command to install MySQL-python

$ tools/with_venv.sh pip install MySQL-python

@ Ken: Thank you. You're right. But I don't understand what's the difference between easy_install and pip command! I will check it later.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.