2 votes

Python mysqldb ne fonctionne pas sur Mac OSX 10.6

J'utilise Python 2.7 et j'essaie de faire fonctionner un projet Django sur un backend MySQL.

J'ai téléchargé mysqldb et suivi le guide ici:http://cd34.com/blog/programming/python/mysql-python-and-snow-leopard/

Pourtant, lorsque j'exécute le projet django, l'erreur suivante se produit :

Traceback (most recent call last):
  File "/Users/andyarmstrong/Documents/workspace/BroadbandMapper/src/BroadbandMapper/manage.py", line 11, in 
    execute\_manager(settings)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/\_\_init\_\_.py", line 438, in execute\_manager
    utility.execute()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/\_\_init\_\_.py", line 379, 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/base.py", line 191, in run\_from\_argv
    self.execute(\*args, \*\*options.\_\_dict\_\_)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 209, in execute
    translation.activate('en-us')
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/translation/\_\_init\_\_.py", line 66, in activate
    return real\_activate(language)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/functional.py", line 55, in \_curried
    return \_curried\_func(\*(args+moreargs), \*\*dict(kwargs, \*\*morekwargs))
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/translation/\_\_init\_\_.py", line 36, in delayed\_loader
    return getattr(trans, real\_name)(\*args, \*\*kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/translation/trans\_real.py", line 193, in activate
    \_active\[currentThread()\] = translation(language)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/translation/trans\_real.py", line 176, in translation
    default\_translation = \_fetch(settings.LANGUAGE\_CODE)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/translation/trans\_real.py", line 159, in \_fetch
    app = import\_module(appname)
  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 1, in 
    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 1, in 
    from django import forms
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/forms/\_\_init\_\_.py", line 17, in 
    from models import \*
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/forms/models.py", line 6, in 
    from django.db import connections
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/\_\_init\_\_.py", line 77, in 
    connection = connections\[DEFAULT\_DB\_ALIAS\]
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 92, 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 33, 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 14, in 
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/andyarmstrong/.python-eggs/MySQL\_python-1.2.3-py2.7-macosx-10.6-x86\_64.egg-tmp/\_mysql.so, 2): Library not loaded: libmysqlclient.16.dylib
  Referenced from: /Users/andyarmstrong/.python-eggs/MySQL\_python-1.2.3-py2.7-macosx-10.6-x86\_64.egg-tmp/\_mysql.so
  Reason: image not found

J'ai également essayé les éléments suivants : http://whereofwecannotspeak.wordpress.com/2007/11/02/mysqldb-python-module-quirk-in-os-x/ en ajoutant un lien entre le répertoire mysql lib et un autre endroit...

Au secours !

2voto

RenegadeAndy Points 969

J'ai finalement réussi à résoudre le problème en installant python 2.7 avec Mac Ports et en installant mysqldb avec Mac Ports - c'était assez simple après cela.

0voto

Pedro Salgado Points 126

Vous deviez ajouter les bibliothèques du client MySQL à LD_LIBRARY_PATH.

Prograide.com

Prograide est une communauté de développeurs qui cherche à élargir la connaissance de la programmation au-delà de l'anglais.
Pour cela nous avons les plus grands doutes résolus en français et vous pouvez aussi poser vos propres questions ou résoudre celles des autres.

Powered by:

X