8

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

asked Jun 3, 2015 at 21:43
2

3 Answers 3

27

The solution was in reinstalling the developer tools:

xcode-select --install
answered Jun 3, 2015 at 22:20
Sign up to request clarification or add additional context in comments.

3 Comments

@viviwill I believe it installs the required version of gcc for compiling mysql
where can I know which version of gcc is required ?
No cure for me.
1

What fixed it for me was:

sudo pip install --upgrade setuptools

Make sure you have mysql installed:

brew install mysql
answered Oct 9, 2017 at 23:02

Comments

0

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.

answered May 24, 2018 at 14:30

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.