python管理。py sql抛出了一个不合适的图像。

时间:2022-01-03 20:33:25

I have macbook pro running OS X 10.7 on Intel processor. I have installed Django 1.3.1, MySQL-python 1.2.3. All the packages installed fine. When I execute command "python manage.py sql poll", I'm running into the following exception.

我有macbook pro在英特尔处理器上运行OS X 10.7。我已经安装了Django 1.3.1、MySQL-python 1.2.3。所有的包都安装好了。当我执行命令“python管理”时。我遇到了下面的异常。

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_manager(settings)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 67, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Library/Python/2.7/site-packages/django/core/management/commands/sql.py", line 4, in <module>
    from django.core.management.sql import sql_create
  File "/Library/Python/2.7/site-packages/django/core/management/sql.py", line 6, in <module>
    from django.db import models
  File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 78, in <module>
    connection = connections[DEFAULT_DB_ALIAS]
  File "/Library/Python/2.7/site-packages/django/db/utils.py", line 93, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/Library/Python/2.7/site-packages/django/db/utils.py", line 33, in load_backend
    return import_module('.base', backend_name)
  File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Library/Python/2.7/site-packages/django/db/backends/mysql/base.py", line 14, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/khoa/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so, 2): no suitable image found.  Did find:
    /Users/khoa/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so: mach-o, but wrong architecture

1 个解决方案

#1


2  

Chances are that the Python you are using (the Apple-supplied Python 2.7.1, perhaps) is running in 64-bit mode but the MySQLdb extension module that you've installed is 32-bit only. Or, possibly, the reverse. The output of this shell command should tell you what architectures the extension module was compiled for:

可能您正在使用的Python(可能是苹果提供的Python 2.7.1)是在64位模式下运行的,但是您已经安装的MySQLdb扩展模块只有32位。或者,可能恰恰相反。这个shell命令的输出应该告诉您扩展模块编译的架构是什么:

file /Users/khoa/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so

The MySQLdb extension module and the MySQL client libraries you've installed must have a common architecture with the architecture that the Python instance you are using.

您安装的MySQLdb扩展模块和MySQL客户端库必须与您正在使用的Python实例的体系结构有共同的体系结构。

#1


2  

Chances are that the Python you are using (the Apple-supplied Python 2.7.1, perhaps) is running in 64-bit mode but the MySQLdb extension module that you've installed is 32-bit only. Or, possibly, the reverse. The output of this shell command should tell you what architectures the extension module was compiled for:

可能您正在使用的Python(可能是苹果提供的Python 2.7.1)是在64位模式下运行的,但是您已经安装的MySQLdb扩展模块只有32位。或者,可能恰恰相反。这个shell命令的输出应该告诉您扩展模块编译的架构是什么:

file /Users/khoa/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so

The MySQLdb extension module and the MySQL client libraries you've installed must have a common architecture with the architecture that the Python instance you are using.

您安装的MySQLdb扩展模块和MySQL客户端库必须与您正在使用的Python实例的体系结构有共同的体系结构。