MacOS X Error when installing python MySQLdb - python

I am trying to install python mysqldb in my mac but I got the following errors. For mysql I am using the one that is bundled with MAMP. Thanks!
here is the error message:
running build
running build_py
copying MySQLdb/release.py -> build/lib.darwin-8.11.1-i386-2.3/MySQLdb
running build_ext
building '_mysql' extension
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/Applications/MAMP/Library/include/mysql -I/System/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3 -c _mysql.c -o build/temp.darwin-8.11.1-i386-2.3/_mysql.o
_mysql.c:36:23: error: my_config.h: No such file or directory
_mysql.c:38:19: error: mysql.h: No such file or directory
_mysql.c:39:26: error: mysqld_error.h: No such file or directory
_mysql.c:40:20: error: errmsg.h: No such file or directory
_mysql.c:76: error: parse error before 'MYSQL'
_mysql.c:76: warning: no semicolon at end of struct or union
_mysql.c:79: error: parse error before '}' token
_mysql.c:79: warning: type defaults to 'int' in declaration of '_mysql_ConnectionObject'
_mysql.c:79: warning: data definition has no type or storage class
....

I guess it's not enough to use the MySQL that's bundled with MAMP, as it does not contain the C development tools for MySQL (i.e. the header files such as mysql.h). Here is a step-by-step tutorial on compiling the MySQL extension for Python on Mac OS X, but it looks like you will need the "official" MySQL distribution for that.

Related

Can't install lxml on OS X 10.8.5

I'm trying to do a malware analysis by using cuckoo sandbox and a VM Machine (WinXP) running on VirtualBox. But however, I can't get cuckoo to run because I haven't installed cybox and maec correctly.
Thus leads me to this problem where I can't get myself to install lxml.
It just won't let me install either by using pip or manual installation with the setup.py file.
Here is what I got:
Building lxml version 3.4.1.
Building without Cython.
Using build configuration of libxslt 1.1.26
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
running install
running bdist_egg
running egg_info
writing requirements to src/lxml.egg-info/requires.txt
writing src/lxml.egg-info/PKG-INFO
writing top-level names to src/lxml.egg-info/top_level.txt
writing dependency_links to src/lxml.egg-info/dependency_links.txt
reading manifest file 'src/lxml.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'src/lxml.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.8-intel/egg
running install_lib
running build_py
copying src/lxml/includes/lxml-version.h -> build/lib.macosx-10.8-intel-2.7/lxml/includes
running build_ext
building 'lxml.etree' extension
clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/usr/include/libxml2 -I/Users/ajprameswari/Downloads/lxml-3.4.1/src/lxml/includes -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.8-intel-2.7/src/lxml/lxml.etree.o -w -flat_namespace
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: command 'clang' failed with exit status 1
I tried both lxml-3.4.0 and lxml-3.4.1 version but they gave the same result.
I'm using Python 2.7 and OS X 10.8.5. Is there anything that could be pointed to help me solve this issue? I'm a newbie in using OS X, I used to work on my Ubuntu, but due to lack spec of my Ubuntu machine I need to work here.
The Apple LLVM compiler in Xcode 5.1 treats unrecognized command-line options as errors. This issue has been seen when building Python native extensions, where some invalid compiler options are specified.
It seems that the newer version of the llvm compiler shipping is a little more restrictive when it comes to warnings.
Fix:
There is a temporary solution to tell the compiler not to raise this error by setting the following environment variables :
sudo -E export CFLAGS=-Qunused-arguments
sudo -E export CPPFLAGS=-Qunused-arguments

Error while installing MySQLdb for Python on Mac OSX 10.6.8 with mysql inside XAMPP

I am trying to import MySQldb in python and call the python script from a php script in XAMPP. Here is what I did:
Environment:
1. Mac OSX 10.6.8
2. Python version 2.6 (default)[64bit]
Done so far:
1. Installed XAMPP
2. MySQL config path: /Applications/XAMPP/xamppfiles/bin/mysql_config
3. Downloaded MySQL-python-1.2.4b4
4. edited the site.cfg with config path for MySQL
5. Ran following commands
sudo python setup.py clean
python setup.py build
Got the following error:
running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb
running build_ext
building '_mysql' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall - Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,4,'beta',4) - D__version__=1.2.4b4 -I/Applications/XAMPP/xamppfiles/include/mysql - I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.6-universal-2.6/_mysql.o -mmacosx-version-min=10.4 -arch i386 -arch ppc -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ - DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL
In file included from _mysql.c:44:
/Applications/XAMPP/xamppfiles/include/mysql/my_config.h:1053:1: warning: "HAVE_WCSCOLL" redefined
In file included from /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:8,
from _mysql.c:29:
/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:803:1 : warning: this is the location of the previous definition
/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/as: assembler (/usr/bin/../libexec/gcc/darwin/ppc/as or /usr/bin/../local/libexec/gcc/darwin/ppc/as) for architecture ppc not installed
Installed assemblers are:
/usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64
/usr/bin/../libexec/gcc/darwin/i386/as for architecture i386
In file included from _mysql.c:44:
/Applications/XAMPP/xamppfiles/include/mysql/my_config.h:1053:1: warning: "HAVE_WCSCOLL" redefined
In file included from /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:8,
from _mysql.c:29: /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:803:1: warning: this is the location of the previous definition
_mysql.c:3131: fatal error: error writing to -: Broken pipe
compilation terminated.
lipo: can't open input file: /var/tmp//ccQsr7Lk.out (No such file or directory)
error: command 'gcc-4.2' failed with exit status 1
yum install mysql-devel
pip install MySQL-python

command 'gcc' failed with exit status 1 (installing psyco)

I run Ubuntu 11.10, gcc version 4.6.1.
I've been trying to install psyco, but keep getting this error:
PROCESSOR = 'i386'
running build
running build_py
running build_ext
building 'psyco._psyco' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DALL_STATIC=1 -Ic/i386 -I/usr/include/python2.7 -c c/psyco.c -o build/temp.linux-i686-2.7/c/psyco.o
In file included from c/initialize.h:55:0,
from c/psyco.c:14:
c/mergepoints.c:242:3: error: ‘JUMP_IF_FALSE’ undeclared here (not in a function)
c/mergepoints.c:242:3: error: ‘JUMP_IF_TRUE’ undeclared here (not in a function)
c/codegen.c:127:19: warning: ‘psyco_source_condition’ defined but not used [-Wunused-function]
c/codegen.c:747:10: warning: ‘integer_lshift’ defined but not used [-Wunused-function]
c/Objects/plistobject.c:115:10: warning: ‘PsycoList_SingletonNew’ defined but not used [-Wunused-function]
error: command 'gcc' failed with exit status 1
I've installed python-setuptools but nothing worked so far. Thanks for a ny suggestions.
Google is your friend: psyco does not build and does not work with Python 2.7, as documented in the corresponding Ubuntu bug report.
Why do you require Psyco? If you need to optimize tight loops, possibly Cython can come to your rescue.
maybe you should get "https://github.com/develersrl/gccwinbinaries" install path :C:/mingw and Installation path :C:/mingw/bin .Finally, find distutils.cfg at the python installation directory D:/Python26/Lib/distutils

Help installing MySQLdb for Python under Mac OS X

I know this has been asked several times, but after a few hours of trying, there is no way to make this work.
I've installed MySQL 32bits from a dmg file and MySQL-python-1.2.3.
I followed this steps, but when I run python setup.py build, these errors come up:
running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.6-fat-2.6/MySQLdb
running build_ext
building '_mysql' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/mysql-5.5.12-osx10.6-x86/include -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.6-fat-2.6/_mysql.o -Os -g -fno-common -fno-strict-aliasing -arch i386
In file included from _mysql.c:36:
/usr/local/mysql-5.5.12-osx10.6-x86/include/my_config.h:326:1: warning: "SIZEOF_SIZE_T" redefined
In file included from /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:9,
from pymemcompat.h:10,
from _mysql.c:29:
/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pymacconfig.h:39:1: warning: this is the location of the previous definition
In file included from _mysql.c:36:
/usr/local/mysql-5.5.12-osx10.6-x86/include/my_config.h:419:1: warning: "HAVE_WCSCOLL" redefined
In file included from /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:8,
from pymemcompat.h:10,
from _mysql.c:29:
/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:803:1: warning: this is the location of the previous definition
_mysql.c:76: error: expected specifier-qualifier-list before ‘MYSQL’
_mysql.c:90: error: expected specifier-qualifier-list before ‘MYSQL_RES’
_mysql.c: In function ‘_mysql_Exception’:
_mysql.c:120: warning: implicit declaration of function ‘mysql_errno’
_mysql.c:120: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:132: error: ‘ER_DB_CREATE_EXISTS’ undeclared (first use in this function)
_mysql.c:132: error: (Each undeclared identifier is reported only once
......
I'd appreciate ANY help you can provide. Thanks!
Try macports:
$ port search python | grep mysql
py-mysql #1.2.2 (python, devel, databases)
Python interface to mysql
py25-mysql #1.2.2 (python, devel, databases)
Python interface to mysql
py26-mysql #1.2.3 (python, devel, databases)
py27-mysql #1.2.2 (python, devel, databases)
Python interface to mysql
My answer here worked for me for both a 32-bit and a 64-bit Mac Snow Leopard install (on two different machines): Installing MySQLdb for Django on Mac OS X 10.6 Snow Leopard with MAMP
Short version:
[user]$ sudo su
[root]# ARCHFLAGS="-arch $(uname -m)" pip install mysql-python
If you don't want to deal with the headache of a package manager on your mac, I've detailed my experience in this installation guide: http://alexandersimoes.com/journal/2011/03/04/install-mysqldb-on-mac-osx-snow-leopard/

Trouble Setting Up MySQLdb Module

I'm pulling my hair out over here trying to set up MySQLdb on my Mac in order to connect to a remote MySQL server.
I have installed the latest C MySQL client libraries
I have installed XCode 4
I did naively try to install the module before installing XCode or the client libraries
I am attempting to set up the module by running the following commands in terminal:
$ sudo python setup.py build
$ sudo python setup.py install
Both of these commands fail with similar error messages. Here is the first stack trace:
running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb
running build_ext
building '_mysql' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/include/mysql -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.6-universal-2.6/_mysql.o -fno-omit-frame-pointer -pipe
In file included from _mysql.c:36:
/usr/include/mysql/my_config.h:1030:2: warning: #warning defining SIZEOF_CHARP = 4
/usr/include/mysql/my_config.h:1044:2: warning: #warning defining SIZEOF_LONG = 4
/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/as: assembler (/usr/bin/../libexec/gcc/darwin/ppc/as or /usr/bin/../local/libexec/gcc/darwin/ppc/as) for architecture ppc not installed
Installed assemblers are:
/usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64
/usr/bin/../libexec/gcc/darwin/i386/as for architecture i386
In file included from _mysql.c:36:
/usr/include/mysql/my_config.h:1030:2: warning: #warning defining SIZEOF_CHARP = 4
/usr/include/mysql/my_config.h:1044:2: warning: #warning defining SIZEOF_LONG = 4
/usr/include/mysql/my_config.h:1151:1: warning: "WORDS_BIGENDIAN" redefined
In file included from /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:8,
from pymemcompat.h:10,
from _mysql.c:29:
/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:1014:1: warning: this is the location of the previous definition
_mysql.c:2888: fatal error: error writing to -: Broken pipe
compilation terminated.
In file included from _mysql.c:36:
/usr/include/mysql/my_config.h:1027:2: warning: #warning defining SIZEOF_CHARP = 8
/usr/include/mysql/my_config.h:1041:2: warning: #warning defining SIZEOF_LONG = 8
lipo: can't open input file: /var/tmp//ccU6bipK.out (No such file or directory)
error: command 'gcc-4.2' failed with exit status 1
And here is the stack trace for the second command:
running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.6-universal/egg
running install_lib
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb
running build_ext
building '_mysql' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/include/mysql -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.6-universal-2.6/_mysql.o -fno-omit-frame-pointer -pipe
In file included from _mysql.c:36:
/usr/include/mysql/my_config.h:1030:2: warning: #warning defining SIZEOF_CHARP = 4
/usr/include/mysql/my_config.h:1044:2: warning: #warning defining SIZEOF_LONG = 4
/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/as: assembler (/usr/bin/../libexec/gcc/darwin/ppc/as or /usr/bin/../local/libexec/gcc/darwin/ppc/as) for architecture ppc not installed
Installed assemblers are:
/usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64
/usr/bin/../libexec/gcc/darwin/i386/as for architecture i386
In file included from _mysql.c:36:
/usr/include/mysql/my_config.h:1030:2: warning: #warning defining SIZEOF_CHARP = 4
/usr/include/mysql/my_config.h:1044:2: warning: #warning defining SIZEOF_LONG = 4
/usr/include/mysql/my_config.h:1151:1: warning: "WORDS_BIGENDIAN" redefined
In file included from /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:8,
from pymemcompat.h:10,
from _mysql.c:29:
/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:1014:1: warning: this is the location of the previous definition
_mysql.c:2888: fatal error: error writing to -: Broken pipe
compilation terminated.
In file included from _mysql.c:36:
/usr/include/mysql/my_config.h:1027:2: warning: #warning defining SIZEOF_CHARP = 8
/usr/include/mysql/my_config.h:1041:2: warning: #warning defining SIZEOF_LONG = 8
lipo: can't open input file: /var/tmp//cchhckGP.out (No such file or directory)
error: command 'gcc-4.2' failed with exit status 1
I have been at this for a few days now and it's starting to drive me nuts. Any help would be greatly appreciated!
You've set yourself up for headaches by installing the new and forward-looking Xcode 4 rather than the latest version of Xcode 3 which is what Mac OS X 10.6 was released with. The immediate issue you are running into is that Python tries to build C extension modules with the same configuration that Python itself was built. For 10.6, that includes three architectures: i386, x86_64, and ppc (for compatibility with programs build on earlier systems). Apparently Xcode 4 has removed support for building ppc archs. You may be able to get around this issue easily by using the ARCHFLAGS environment variable which is used to override the arch settings used by Python's Distutils when building extension modules. Try doing something like this (untested as I don't have Xcode 4 handy):
sudo bash
export ARCHFLAGS='-arch i386 -arch x86_64'
rm -r build
python setup.py build
python setup.py install
A better solution, as recommended elsewhere, is to not try to install MySQLdb on 10.6 by using the system Python and the MySQL binary installers. Rather, use a complete solution by installing everything via a package manager like MacPorts.
There is another way that I just found to solve this.
I encountered the same problem as you did, and my python's version is 2.7.4, and Xcode 4. Maybe you have just got the python of 32 bits, as I did. So I changed it to 2.7.5x64bit, then there should be no problems.

Categories