Publicado por Juan Pablo el 26.Sep.2008 | Comentarios (0)
Guía rápida y sin más explicaciones de como instalar la interface MySQLdb —desarrollada y mantenida por Andy Dustman — en un sistema Mac OS X 10.5 (leopard).
Se verifica que el módulo NO está instalado:
$ python Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information.
Tepea:
>>> import MySQLdb
Si el mensaje es el siguiente debes instalar MySQLdb:
Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named MySQLdb
Descargar y descomprimir MySQLdb:
$ curl -O http://ufpr.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.2.tar.gz $ tar -xvzf MySQL-python-1.2.2.tar.gz $ cd MySQL-python-1.2.2
Editar la ruta para mysql_config (si está en otro lugar cambialo según tu setup)
$ vi setup_posix.py
Aproximadamente en la línea 26 cambiar:
mysql_config.path = "mysql_config"
Por:
mysql_config.path = "/usr/local/mysql/bin/mysql_config"
$ python setup.py clean running clean
$ python setup.py build
Si aparece un error como el siguiente:
/usr/include/sys/types.h:92: error: duplicate 'unsigned' /usr/include/sys/types.h:92: error: two or more data types in declaration specifiers
Debes editar el archivo _mysql.c
$ vi _mysql.c
Aproximadamente en la linea 38 debes dejar en comentario:
#define uint unsigned int
Es decir, debe quedar:
//#define uint unsigned int
Nuevamente:
$ python setup.py build
Y luego:
$ sudo python setup.py install
Verificamos que se ha instalado correctamente volviendo a la consola python:
$ python >>> import MySQLdb >>> MySQLdb.__version__ '1.2.2' >>>
Voila y Fin.
Enlace Permanente, Comentarios (0), Publicada en: Python