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?
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:
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.
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
@ 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.