0

I've been searching through SO, forums, and blog posts for over 24 hours. Frankly, I have absolutely no idea what's going on anymore. This seems like a complicated issue, so I'll post as clearly as I can.

I am using Django, and am trying to switch from sqlite to mysql. I followed the instructions from this SO answer to do so: https://stackoverflow.com/a/3036241

When I run the last line, python manage.py loaddata datadump.json (or when I try to run python manage.py syncdb for that matter), I get the following error:

File "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-1.4-py2.7.egg/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/management/__init__.py", line 382, 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-1.4-py2.7.egg/django/core/management/__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/management/__init__.py", line 69, 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-1.4-py2.7.egg/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-1.4-py2.7.egg/django/core/management/commands/loaddata.py", line 13, in <module>
    from django.core import serializers
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/serializers/__init__.py", line 21, in <module>
    from django.core.serializers.base import SerializerDoesNotExist
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/serializers/base.py", line 7, in <module>
    from django.db import models
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/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-1.4-py2.7.egg/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-1.4-py2.7.egg/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-1.4-py2.7.egg/django/db/utils.py", line 24, in load_backend
    return import_module('.base', backend_name)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/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-1.4-py2.7.egg/django/db/backends/mysql/base.py", line 16, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

So, I searched around to see how to solve this, and tried this:

pip install MySQL-python

As soon as I ran that line, I got the following error:

Downloading/unpacking MySQL-python
  Running setup.py egg_info for package MySQL-python
    sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/var/folders/9q/bvqtzkbx1hg1934b36zgk0y40000gn/T/pip-build/MySQL-python/setup.py", line 18, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 25, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    Complete output from command python setup.py egg_info:
    sh: mysql_config: command not found

Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/var/folders/9q/bvqtzkbx1hg1934b36zgk0y40000gn/T/pip-build/MySQL-python/setup.py", line 18, in <module>

    metadata, options = get_config()

  File "setup_posix.py", line 43, in get_config

    libs = mysql_config("libs_r")

  File "setup_posix.py", line 25, in mysql_config

    raise EnvironmentError("%s not found" % (mysql_config.path,))

EnvironmentError: mysql_config not found

Tried it with easy_install, just to make sure. Same error.

So, then I tried to change the path to mysql_config in setup_posix.py, by following steps 5 and 6 from this SO answer: https://stackoverflow.com/a/1448476/1337422

When I moved on to step 7 of that answer, and ran sudo python setup.py build, I got the following error:

running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb
running build_ext
building '_mysql' extension
gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -O3 -Dversion_info=(1,2,4,'beta',4) -D__version__=1.2.4b4 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.3-fat-2.7/_mysql.o -Os -g -fno-common -fno-strict-aliasing -arch x86_64
unable to execute gcc-4.0: No such file or directory
error: command 'gcc-4.0' failed with exit status 1

For this, I've found no cure.


By the way, I also followed the instructions on this answer: https://stackoverflow.com/a/1448446/1337422, and ran: sudo port install py26-mysql

This appeared to have fixed nothing.

(I'm running on Mac OS 10.8.1)


I am so lost, and so hopeless at this point. I don't know where else to turn...help me out guys!

Community
  • 1
  • 1
sgarza62
  • 5,998
  • 8
  • 49
  • 69

1 Answers1

1

The clue is here:

unable to execute gcc-4.0: No such file or directory
error: command 'gcc-4.0' failed with exit status 1

You need to install the compiler... I'm not a Mac user, but a quick Google came up with http://www.tech-recipes.com/rx/726/mac-os-x-install-gcc-compiler/ which might help

Looks like sudo port install gcc_select and then sudo port install gcc<nnn> is about the right lines...

Jon Clements
  • 138,671
  • 33
  • 247
  • 280
  • I'm not certain, but I think it's already installed. When I run `gcc -v`, it returns `...Thread model: posix` `gcc version 4.2.1...`. – sgarza62 Nov 13 '12 at 08:25
  • Based on your **edit**, I used `sudo port install gcc_select` to install. When I ran `sudo port install gcc`, it returned this error: `-bash: syntax error near unexpected token 'newline'` Any thoughts? – sgarza62 Nov 13 '12 at 08:34
  • @sgarza62 Sorry - the `` should be the relevant version number... – Jon Clements Nov 13 '12 at 08:45
  • All installed perfectly, but I'm still getting the same gcc-4.0 error :( – sgarza62 Nov 13 '12 at 17:49
  • I'm outta ideas (and hungry) - what happens if you do `which gcc-4.0` ? (I assume `which` works on OSX) – Jon Clements Nov 13 '12 at 17:50
  • I would buy you a sandwich if I could, thanks for all your help. If I type `which gcc-4.0`, nothing happens. However, if I type `which gcc`, it returns `/usr/bin/gcc`. Also, if I type `gcc`, it returns `i686-apple-darwin11-llvm-gcc-4.2: no input files`. – sgarza62 Nov 13 '12 at 18:02
  • @sgarza62 Can you symlink gcc-4.0 to gcc (or search/replace gcc-4.0 with gcc throughout the build instructions)? – Jon Clements Nov 13 '12 at 18:04
  • I followed the directions at http://www.question-defense.com/2010/03/30/how-to-switch-between-different-versions-of-gcc-and-g-in-backtrack-4-final-or-any-version-of-ubuntu to create a symlink (want it to use gcc-4.0), and it told me to `rm /usr/bin/gcc` first. Then I did this `ln -s /usr/bin/gcc-4.0 /usr/bin/gcc`. Now, when I type which gcc or which gcc-4.0, nothing happens at all. I think that may have made it worse...what a mess. – sgarza62 Nov 13 '12 at 18:17