Error when installing MySQL-python with pip install in OSX, virtualenv

pip install mysql-python error
pip install mysqlclient fails mac
install mysql-python on mac
install mysql client mac
install mysql pip mac
_mysql.c:44:10: fatal error: 'my_config.h' file not found
django mysql setup mac
oserror: mysql_config not found mac

First i'm developing a django app, when i try to run the server with:

python manage.py runserver 0.0.0.0:8000

The terminal shows:

 "django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb"

So, i need to install that package:

(app1)Me% pip install MySQL-python

Errors:

Collecting mysql-python
  Using cached MySQL-python-1.2.5.zip
Building wheels for collected packages: mysql-python
  Running setup.py bdist_wheel for mysql-python
  Complete output from command /Users/GFTecla/Documents/shoutout/bin/python -c "import setuptools;__file__='/private/var/folders/9g/1qrws9yj3wn7lghlrpgyh9cc0000gn/T/pip-build-ZMQOQm/mysql-python/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /var/folders/9g/1qrws9yj3wn7lghlrpgyh9cc0000gn/T/tmp1JfTpfpip-wheel-:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.5-intel-2.7
  copying _mysql_exceptions.py -> build/lib.macosx-10.5-intel-2.7
  creating build/lib.macosx-10.5-intel-2.7/MySQLdb
  copying MySQLdb/__init__.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb
  copying MySQLdb/converters.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb
  copying MySQLdb/connections.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb
  copying MySQLdb/cursors.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb
  copying MySQLdb/release.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb
  copying MySQLdb/times.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb
  creating build/lib.macosx-10.5-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/CR.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/ER.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb/constants
  running build_ext
  building '_mysql' extension
  creating build/temp.macosx-10.5-intel-2.7
  gcc -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/Cellar/mysql/5.6.23/include/mysql -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.5-intel-2.7/_mysql.o -g -fno-omit-frame-pointer -fno-strict-aliasing
  In file included from _mysql.c:44:
  /usr/local/Cellar/mysql/5.6.23/include/mysql/my_config.h:348:11: warning: 'SIZEOF_SIZE_T' macro redefined
    #define SIZEOF_SIZE_T  SIZEOF_LONG
            ^
  /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pymacconfig.h:43:17: note: previous definition is here
  #        define SIZEOF_SIZE_T           8
                  ^
  In file included from _mysql.c:44:
  /usr/local/Cellar/mysql/5.6.23/include/mysql/my_config.h:442:9: warning: 'HAVE_WCSCOLL' macro redefined
  #define HAVE_WCSCOLL
          ^
  /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:911:9: note: previous definition is here
  #define HAVE_WCSCOLL 1
          ^
  _mysql.c:1589:10: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
          if (how < 0 || how >= sizeof(row_converters)) {
              ~~~ ^ ~
  3 warnings generated.
  gcc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -isysroot / -Qunused-arguments -Qunused-arguments build/temp.macosx-10.5-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql/5.6.23/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.5-intel-2.7/_mysql.so
  ld: library not found for -lbundle1.o
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for mysql-python
Failed to build mysql-python
Installing collected packages: mysql-python
  Running setup.py install for mysql-python
    Complete output from command /Users/GFTecla/Documents/shoutout/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/9g/1qrws9yj3wn7lghlrpgyh9cc0000gn/T/pip-build-ZMQOQm/mysql-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/9g/1qrws9yj3wn7lghlrpgyh9cc0000gn/T/pip-YOrOKA-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/GFTecla/Documents/shoutout/bin/../include/site/python2.7/mysql-python:
    running install
    running build
    running build_py
    copying MySQLdb/release.py -> build/lib.macosx-10.5-intel-2.7/MySQLdb
    running build_ext
    building '_mysql' extension
    gcc -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/Cellar/mysql/5.6.23/include/mysql -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.5-intel-2.7/_mysql.o -g -fno-omit-frame-pointer -fno-strict-aliasing
    In file included from _mysql.c:44:
    /usr/local/Cellar/mysql/5.6.23/include/mysql/my_config.h:348:11: warning: 'SIZEOF_SIZE_T' macro redefined
      #define SIZEOF_SIZE_T  SIZEOF_LONG
              ^
    /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pymacconfig.h:43:17: note: previous definition is here
    #        define SIZEOF_SIZE_T           8
                    ^
    In file included from _mysql.c:44:
    /usr/local/Cellar/mysql/5.6.23/include/mysql/my_config.h:442:9: warning: 'HAVE_WCSCOLL' macro redefined
    #define HAVE_WCSCOLL
            ^
    /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:911:9: note: previous definition is here
    #define HAVE_WCSCOLL 1
            ^
    _mysql.c:1589:10: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
            if (how < 0 || how >= sizeof(row_converters)) {
                ~~~ ^ ~
    3 warnings generated.
    gcc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -isysroot / -Qunused-arguments -Qunused-arguments build/temp.macosx-10.5-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql/5.6.23/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.5-intel-2.7/_mysql.so
    ld: library not found for -lbundle1.o
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/Users/GFTecla/Documents/shoutout/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/9g/1qrws9yj3wn7lghlrpgyh9cc0000gn/T/pip-build-ZMQOQm/mysql-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/9g/1qrws9yj3wn7lghlrpgyh9cc0000gn/T/pip-YOrOKA-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/GFTecla/Documents/shoutout/bin/../include/site/python2.7/mysql-python" failed with error code 1 in /private/var/folders/9g/1qrws9yj3wn7lghlrpgyh9cc0000gn/T/pip-build-ZMQOQm/mysql-python

I have OS X 10.10.2

Django 1.8.2

Python 2.7


The solution was in reinstalling the developer tools:

xcode-select --install

Wheel file not used when installing mysql-python on MacOs · Issue , Installing mysql-python with pip succeeds, but with pipenv it fails. With pip (in an empty virtualenv with the same python): pipenv, version 2018.05.18 Python 2.7.15 (Homebrew python@2) pip 10.0.1 from /T/pip-install-m6iEmd/mysql-​python/ Error: An error occurred while installing mysql-python! Python has support for working with databases via a simple API. Modules included with Python include modules for SQLite and Berkeley DB. Modules for MySQL ,


What fixed it for me was:

sudo pip install --upgrade setuptools

Make sure you have mysql installed:

brew install mysql

Can't install mysqlclient on MacOS · Issue #131 · PyMySQL , include/site/python3.5/mysqlclient" failed with error code 1 in Running pip install -v mysqlclient I'm getting this: egg_info for package mysqlclient Running command python setup.py egg_info running egg_info /codefu/devel/web.​hosting/.venv/lib/python3.5/site-packages/pip/commands/install.py", line  Installing packages using pip and virtual environments¶ This guide discusses how to install packages using pip and a virtual environment manager: either venv for Python 3 or virtualenv for Python 2. These are the lowest-level tools for managing Python packages and are recommended if higher-level tools do not suit your needs.


Based on a solution to a seemingly unrelated problem, I was able to solve the problem here by running brew doctor and cleaning up all the stray header files it called out.

Install MySQL and MySQLClient(Python) in MacOS, Connecting to MySQL from Python in MacOS is a very problematic and painful process. You should be able to use pip install mysqlclient without any errors. In this article, we have seen installing MySQL from Homebrew. It is always accessible and straightforward to install any module using pip in python. MySQL Connector Python is available on pypi.org so you can install using pip command. Using pip command, you can install MySQL Connector python on any operating system platform including Windows, macOS, Linux, and Unix and Ubuntu.


Mac OS X, pip install mysql-python fails with EnvironmentError: mysql_config not found ImproperlyConfigured("Error loading MySQLdb module: %s" % e) ImproperlyConfigured: Error loading MySQLdb module: No module named Cannot uninstall requirement mysql-python, not installed Please note I'm not in a virtualenv. python  Installing MySQL-python (MySQLdb) in a virtualenv on OSX 10.6 There were two problems with the MySQL-Python package that I had when installing on OS X 10.6 1) First, an error saying "EnvironmentError: mysql_config not found" when setup.py is run (through pip or easy_install)


pipenv install mysqlclient on MacOSX - Shan Dou, pipenv has won me over as the go-to tool for python packaging and environment management. Using it An error occurred while installing mysqlclient==1.3.14  Virtualenv is a tool used to create an isolated Python environment. This environment has its own installation directories that doesn't share libraries with other virtualenv environments (and optionally doesn't access the globally installed libraries either). Virtualenv is the easiest and recommended way to configure a custom Python environment.


Pip3 install mysqlclient mac error, 3+ the built-in venv module is used, instead of the third-party virtualenv utility. python. Once pip says that you have Successfully installed mysqlclient you are  Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.