Installing MySQL-python causes command ‘clang’ failed with exit status 1 on Mac OS 10.13.15

I just resolved this exact issue when running Ansible’s mysql_user module. The answer here helped tip me off to a solution. I also needed MySQL-python from pip, which also broke in this process, so I’ve added the extra steps.

Steps to resolve:

  1. brew unlink mysql # only if installed, causes the next step to fail
  2. brew install mysql-connector-c
  3. locate mysql_config file with which (mysql_config)
  4. edit the mysql_config file, under # Create options change this: libs="$libs -l " to this: libs="$libs -lmysqlclient -lssl -lcrypto" if using vim, :wq! to save the read-only file
  5. Now the install should run successfully pip install mysqlclient
  6. Adding this separately, as it’s similar but not directly related to the initial question pip install MySQL-python
  7. Fix mysql brew formula, if it was unlinked in the first step. brew unlink mysql-connector-c brew link mysql

Leave a Comment