I'm trying to use

pip install mysql-python

inside a virtualenv container and am getting the error

building '_mysql' extension

gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,2,4,'final',1) -D__version__=1.2.4 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -fPIC -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1

_mysql.c:1:0: error: CPU you selected does not support x86-64 instruction set

error: command 'gcc' failed with exit status 1

Why is gcc trying to use -march=i686 when I'm on a 64-bit system and using a 64-bit version of Python?


1 Answer 1


You can set your architecture manually by setting the CFLAGS environmental variable.

CFLAGS='-march=x86-64' pip install mysql-python

This variable's contents are appended to gcc's argument list.

  • Thank you - I eventually got it working using x86-64 as the architecture (hyphen as opposed to underscore)
    – Matt Healy
    Jul 8, 2013 at 10:16
  • I have modified my answer to account for that.
    – user26112
    Jul 8, 2013 at 12:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .