Sahara ImportError: No module named MySQLdb

asked 2014-12-06 04:17:59 -0500

ash gravatar image

updated 2014-12-06 21:19:04 -0500

I have Ubuntu OpenStack Icehouse To install Sahara I am using this guide

connection in my /etc/sahara/sahara.conf is

connection = mysq://sahara:pwd@controller/sahara

When I try to create dabase shema

sahara-db-manage --config-file /etc/sahara/sahara.conf upgrade head

and I found ImportError: No module named MySQLdb

I already have python-mysqldb installed. But the problem is not solved. I need urgent help.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2014-12-06 07:03:58 -0500

9lives gravatar image

Please check this the solution is install the MySQL-python package by pip

pip install MySQL-python

Hope that helps!


edit flag offensive delete link more


i have tried you suggestion

import MySQLdb

but still there is problem, no difference. When I execute;

sahara-venv/bin/sahara-db-manage --config-file sahara-venv/etc/sahara.conf upgrade head

I receive:

ImportError: No module named MySQLdb):
ash gravatar imageash ( 2014-12-06 21:21:46 -0500 )edit

answered 2014-12-06 09:22:44 -0500

dbaxps gravatar image


sudo apt-get install python-pip libmysqlclient-dev python-dev


sudo pip install MySQL-python
Downloading/unpacking MySQL-python
  Downloading (108kB): 108kB downloaded
  Running (path:/tmp/pip_build_root/MySQL-python/ egg_info for package MySQL-python

Installing collected packages: MySQL-python
  Running install for MySQL-python
    building '_mysql' extension
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g -DNDEBUG
    In file included from _mysql.c:44:0:
    /usr/include/mysql/my_config.h:422:0: warning: "HAVE_WCSCOLL" redefined [enabled by default]
     #define HAVE_WCSCOLL
    In file included from /usr/include/python2.7/pyconfig.h:3:0,
                     from /usr/include/python2.7/Python.h:8,
                     from _mysql.c:29:
    /usr/include/x86_64-linux-gnu/python2.7/pyconfig.h:911:0: note: this is the location of the previous definition
     #define HAVE_WCSCOLL 1
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib/x86_64-linux-gnu -lmysqlclient_r -lpthread -lz -lm -ldl -o build/lib.linux-x86_64-2.7/

Successfully installed MySQL-python
Cleaning up...
edit flag offensive delete link more


I followed these commands and executed Import MySQLdb

but there is same error, is there problem with my connection string?

ash gravatar imageash ( 2014-12-06 21:26:14 -0500 )edit

None of these attempts worked for me too.

YAPPO gravatar imageYAPPO ( 2015-03-05 04:07:52 -0500 )edit

I found out that I used virtual environment incorrectly, so local python didn't see modules that were added by pip install.

YAPPO gravatar imageYAPPO ( 2015-03-06 03:36:35 -0500 )edit

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2014-12-06 04:17:59 -0500

Seen: 2,053 times

Last updated: Dec 06 '14