wrong architecture error

2012-11-15
2013-07-16
  • Ralph Grove
    Ralph Grove
    2012-11-15

    I just installed mysql-python, and am getting this error when I try to run it. The same error also pops up when I try to run django commands that access the database.

    python tests/test_MySQLdb_capabilities.py
    Traceback (most recent call last):
    File "tests/test_MySQLdb_capabilities.py", line 4, in
    import MySQLdb
    File "/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/MySQLdb/init.py", line 19, in
    import _mysql
    ImportError: dlopen(/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/_mysql.so, 2): no suitable image found. Did find:
    /Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/_mysql.so: mach-o, but wrong architecture

    It's running on Mac OS 10.8.2, with Python 2.7.2, and MySQL 5.5.28

    Thanks for any advice.

     
  • Andy Dustman
    Andy Dustman
    2012-11-15

    How did you install it? 1.2.4b4 is out of date. I recommend you use:

    $ pip install MySQL-python

    This will ensure you get the latest release candidate. And if you don't have pip:

    http://www.pip-installer.org/en/latest/

     
  • Ralph Grove
    Ralph Grove
    2012-11-15

    I originally downloaded v1.2.4b4 from https://sourceforge.net/projects/mysql-python/ and then executed build and install commands.

    I just tried uninstalling and reinstalling with pip, which upgraded it to v1.2.4c1. However, the problem is still there. This is the output of an attempt to build a mysql database using django.

    ip96-62:mysite groverf$ python manage.py syncdb
    Traceback (most recent call last):
    File "manage.py", line 10, in
    execute_from_command_line(sys.argv)
    File "/Library/Python/2.7/site-packages/django/core/management/init.py", line 443, in execute_from_command_line
    utility.execute()
    File "/Library/Python/2.7/site-packages/django/core/management/init.py", line 382, 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 69, 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/syncdb.py", line 8, in
    from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
    File "/Library/Python/2.7/site-packages/django/core/management/sql.py", line 6, in
    from django.db import models
    File "/Library/Python/2.7/site-packages/django/db/init.py", line 40, in
    backend = load_backend(connection.settings_dict['ENGINE'])
    File "/Library/Python/2.7/site-packages/django/db/init.py", line 34, in getattr
    return getattr(connections[DEFAULT_DB_ALIAS], item)
    File "/Library/Python/2.7/site-packages/django/db/utils.py", line 92, in getitem
    backend = load_backend(db['ENGINE'])
    File "/Library/Python/2.7/site-packages/django/db/utils.py", line 24, 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 16, in
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
    django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Library/Python/2.7/site-packages/_mysql.so, 2): no suitable image found. Did find:
    /Library/Python/2.7/site-packages/_mysql.so: mach-o, but wrong architecture

     
  • Andy Dustman
    Andy Dustman
    2012-11-16

    Well, it's definitely odd. Can you try creating a virtualenv environment and installing MySQLdb in there?

    Are you sure your MySQL installation is correct? If you downloaded from http://www.mysql.com/downloads/mysql/#downloads specifically which one? You need to make sure the architecture of Python and MySQL match. Probably the best way to test this is with the following commands:

    $ file `which python`
    $ file `which mysql` # or mysql_config
    $ file /Library/Python/2.7/site-packages/_mysql.so
    

    They should either all be x86-64 or i386 but not a mix.

     
  • Ralph Grove
    Ralph Grove
    2012-11-16

    The MySQL installer I used is: mysql-5.5.28-osx10.6-x86.dmg

    python supports both architectures, and the other two are i386. I also tried running Python with "arch -i386 python", but it made no difference

    file which python
    /usr/bin/python: Mach-O universal binary with 2 architectures
    /usr/bin/python (for architecture i386): Mach-O executable i386
    /usr/bin/python (for architecture x86_64): Mach-O 64-bit executable x86_64
    ip96-62:mysite groverf$ file which mysql
    /Users/groverf/bin/mysql: POSIX shell script text executable
    ip96-62:mysite groverf$ file /usr/local/mysql/bin/mysql
    /usr/local/mysql/bin/mysql: Mach-O executable i386
    ip96-62:mysite groverf$ file /Library/Python/2.7/site-packages/_mysql.so
    /Library/Python/2.7/site-packages/_mysql.so: Mach-O bundle i386
    ip96-62:mysite groverf$

     
  • Andy Dustman
    Andy Dustman
    2012-11-16

    I knew there had to be a fat binary in there somewhere... So you are linked against an i386 MySQL library. I think if you get the 64-bit MySQL build, your problem will go away.

     
  • Ralph Grove
    Ralph Grove
    2012-11-16

    I did this:
    1. uninstall MySQL and mysql-python
    2. reinstall MySQL 64-bit
    3. reinstall mysql-python
    (at this point, the django syncdb command was failing due to a missing library, libmysqlclient.18.dylib)
    4. added environment variable DYLD_LIBRARY_PATH=/usr/local/mysql...../lib, to point to the directory containing the missing dylib

    With those changes, the django syncdb command is now working correctly with a mysql database.

    Thanks for your help.

     
    • Adam Nelson
      Adam Nelson
      2012-11-16

      Did you install mysql via homebrew since you're on a Mac?

      On Fri, Nov 16, 2012 at 9:54 AM, Ralph Grove groverf@users.sf.net wrote:

      I did this:
      1. uninstall MySQL and mysql-python
      2. reinstall MySQL 64-bit
      3. reinstall mysql-python
      (at this point, the django syncdb command was failing due to a missing
      library, libmysqlclient.18.dylib)
      4. added environment variable DYLD_LIBRARY_PATH=/usr/local/mysql...../lib,
      to point to the directory containing the missing dylib

      With those changes, the django syncdb command is now working correctly
      with a mysql database.

      Thanks for your help.

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/mysql-python/discussion/70460/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/prefs/

      --
      Adam

       
  • Andy Dustman
    Andy Dustman
    2012-11-16

    I'm pretty sure he's not using homebrew or MacPorts.

    I'm not sure what the "right way" to solve this problem is, but, could you post the output of running mysql_config?

     
  • Let's solve the problem.So post the config.