0

Help I'm stuck in Django hell! I'm trying to learn Django and I'm trying to set up a test site on my own computer (MacOS 10.12.6). My version of Python is 3.6.2 with Django 1.11.4 and MySQL 5.7.19.

I am at the point where I want to do:

python manage.py migrate

BUT... it doesn't work... I have installed mysql-connector 2.1.6 and that particular version seems to have a bug which is documented here. The error posted looks like mine. MySQL said the bug was fixed in version 2.1.7, but I can't download that with pip and I don't see it anywhere. The only other version higher that pip sees is 2.2.3 and that doesn't install at all.

I found other instructions that suggested using mysqlclient (and here), but even that doesn't work. I get this error...

pip install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-1.3.10.tar.gz
    Complete output from command python setup.py egg_info:
    /bin/sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/d9/z3yxpfl505s_jwtty_x3576h0000gn/T/pip-build-8vj20eqa/mysqlclient/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "/private/var/folders/d9/z3yxpfl505s_jwtty_x3576h0000gn/T/pip-build-8vj20eqa/mysqlclient/setup_posix.py", line 44, in get_config
        libs = mysql_config("libs_r")
      File "/private/var/folders/d9/z3yxpfl505s_jwtty_x3576h0000gn/T/pip-build-8vj20eqa/mysqlclient/setup_posix.py", line 26, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    OSError: mysql_config not found

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/d9/z3yxpfl505s_jwtty_x3576h0000gn/T/pip-build-8vj20eqa/mysqlclient/

I hope someone can help me get past this since I'm definitely stuck at this point. Thank you in advance!

-b

B Smith
  • 19
  • 3
  • Are you sure you have MySQL or the tools installed? – The_Cthulhu_Kid Aug 17 '17 at 05:31
  • 2
    I think I figured it out... I had to add the path to mysql_config to $PATH... Can I delete a question if I solve it myself :/ – B Smith Aug 17 '17 at 05:39
  • Don't delete the question. This question might be helpful o future readers. Accept the answer which helped you most. @BSmith – Arpit Solanki Aug 17 '17 at 05:48
  • YES -- that's what it was... I needed to add "/usr/local/mysql/bin" to my $PATH and I was able to get mysqlclient installed. Once I changed the ENGINE setting back to 'django.db.backends.mysql' -- I was able to get past this step. I'll vote to delete it if no one finds it useful. – B Smith Aug 17 '17 at 05:50
  • Sorry, the posted answer Mohideen had nothing to do with this problem, but appreciate everyone's help (and eyes). – B Smith Aug 17 '17 at 05:51

2 Answers2

1

I think you have issue in your Mysql connectors.. so try these,

sudo apt-get install mysql-server

mysql-config is in a different package, which can be installed from:

sudo apt-get install libmysqlclient-dev
Mohideen bin Mohammed
  • 18,813
  • 10
  • 112
  • 118
1

This was the clue, unfortunately, I understood it after I posted my question:

/bin/sh: mysql_config: command not found

I thought that the path to the MySQL executables was correct, but it wasn't. I added this to my .bash_profile file:

export PATH=$PATH:/usr/local/mysql/bin

and then changed the ENGINE setting in settings.py back to:

'ENGINE': 'django.db.backends.mysql',

..and the migrations went fine.

B Smith
  • 19
  • 3