Django configuration error using python-mysql on Mac OS 10.6.6

My setup:

  • Mac OS 10.6.6 - x86_64
  • MySQL 5.5.8
  • Python 2.7.1
  • Django 1.2.5
  • mysql-python installed with easy_install

My situation:

I'm struggling to get my installation to work. The problem is the mysql-python interface. I initially had a similar problem (with the one that I have with Django) executing the import statement in python:

import MySQLdb

But I read this question / solution , which turned out to be successful in resolving it. I installed django and it works fine, but it has problems with the mysql interface. When I start the terminal and print:

>> python manage.py dbshell

The following error is generated:

Traceback ( ):    "manage.py", 11,     execute_manager ()    "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/ init.py", 438, exec_manager     utility.execute()    "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/ init.py", 379,     self.fetch_command ().run_from_argv (self.argv)    "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/ init.py", 261, fetch_command     klass = load_command_class (app_name, )    "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/ init.py", 67, load_command_class     module = import_module ('% s.management.commands.% s'% (_, ))    "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", 35, import_module      ()    "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/dbshell.py", 4,      django.db, DEFAULT_DB_ALIAS    "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/ init.py", 77,     connection = connections [DEFAULT_DB_ALIAS]    "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", 92, getitem    backend = load_backend (db ['ENGINE'])    "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", 33, load_backend     return import_module ('. base', backend_name)    "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", 35, import_module      ()    "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", 14,     raise ( " MySQLdb:% s" % e) django.core.exceptions.ImproperlyConfigured: MySQLdb: dlopen (/Users/adogc45/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so, 2 ): : libmysqlclient.16.dylib   :/Users/adogc45/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so   :

, Python , mysql django .

, settings.py :

DATABASES = {
'default': {
    'ENGINE': 'mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.

, ... /MySQL _python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp

, , .

+3
3

export DYLD_LIBRARY_PATH =/usr/local/mysql/lib: $DYLD_LIBRARY_PATH

:

pip install MySQL-python
pip install --upgrade MySQL-python

+5

, , .bash_profile ( ~, ): export DYLD_LIBRARY_PATH =/usr/local/mysql/lib/ libmysqlclient.16.dylib.

, Apache wsgi python, Apache libmysqlclient.16.dylib , . sys.path.append( '/USR//MySQL/Lib') os.environ ['DYLD_LIBRARY_PATH'] = '/usr/local/mysql/lib' ... , Apache , python ( .bash_profile)... help!!!

+2

Try:

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.mysql',

Instead mysql, if you are using Django 1.2.5.

0
source

Source: https://habr.com/ru/post/1796214/


All Articles