mysqldb python macos python-2.7 mysql-python

mysqldb python install



Instalando MySQL-python en mac (3)

Estoy usando OSX 10.8 y PyCharm para trabajar en un proyecto de desarrollo de Python. He instalado MySQL-python para mac usando las instrucciones en el sitio web

http://blog.infoentropy.com/MySQL-python_EnvironmentError_mysql_config_not_found

Sin embargo, ejecutar el proyecto me da este error:

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/ashishagarwal/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so, 2): Symbol not found: _mysql_affected_rows Referenced from: /Users/ashishagarwal/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so Expected in: flat namespace in /Users/ashishagarwal/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so

El archivo mencionado int en el error existe en la ubicación - /Users/ashishagarwal/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so

El mensaje de error completo es -

/usr/local/bin/python2.7-32 /Users/ashishagarwal/Optimus/MashPotato/backend/mashpotato/manage.py testserver --addrport 8000 Running on development server Traceback (most recent call last): File "/Users/ashishagarwal/Optimus/MashPotato/backend/mashpotato/manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line utility.execute() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command klass = load_command_class(app_name, subcommand) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 77, in load_command_class module = import_module(''%s.management.commands.%s'' % (app_name, name)) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/south/management/commands/__init__.py", line 10, in <module> import django.template.loaders.app_directories File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/loaders/app_directories.py", line 23, in <module> mod = import_module(app) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 3, in <module> from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/admin/helpers.py", line 4, in <module> from django.contrib.admin.util import (flatten_fieldsets, lookup_field, File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/admin/util.py", line 6, in <module> from django.db import models File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/__init__.py", line 40, in <module> backend = load_backend(connection.settings_dict[''ENGINE'']) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__ return getattr(connections[DEFAULT_DB_ALIAS], item) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 93, in __getitem__ backend = load_backend(db[''ENGINE'']) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 27, in load_backend return import_module(''.base'', backend_name) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 17, in <module> raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/ashishagarwal/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so, 2): Symbol not found: _mysql_affected_rows Referenced from: /Users/ashishagarwal/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so Expected in: flat namespace in /Users/ashishagarwal/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so Process finished with exit code 1


Asegúrese de tener la versión más reciente de Xcode, incluidas las herramientas de línea de comandos. Simplemente descargué la actualización de 2GB de la tienda de aplicaciones. Tuve un problema similar, específicamente this , y eso lo solucionó.

¡Aclamaciones!


Primero debe instalar MySQL a través de Homebrew , para que python-mysql funcione correctamente en OS X.

pip uninstall MySQL-python brew install mysql pip install MySQL-python


si usas Python como:

import mysql.connector

tienes que descargar el conector mysql primero aquí está el enlace de link