Error Connection in MySQLdb and Python in MAC OS X.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cnivas
    New Member
    • Feb 2009
    • 8

    Error Connection in MySQLdb and Python in MAC OS X.

    Hi,
    I'm doing a small project on Python using MySQL as Database in MAC OS X.
    I was unable to connect the database. I was downloaded MySQLdb from sourceforge.net and I also modified setup_posix.py. After modified and restart the setup.py I'm getting an error "gcc" cannot find the file.
    This is the error it was getting when I was reinstalling the setup.py
    "Administrator: MySQL-python-1.2.2 administrator$ sudo python setup.py install
    running install
    running bdist_egg
    running egg_info
    writing MySQL_python.eg g-info/PKG-INFO
    writing top-level names to MySQL_python.eg g-info/top_level.txt
    writing dependency_link s to MySQL_python.eg g-info/dependency_link s.txt
    reading manifest file 'MySQL_python.e gg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'MySQL_python.e gg-info/SOURCES.txt'
    installing library code to build/bdist.macosx-10.3-fat/egg
    running install_lib
    running build_py
    copying MySQLdb/release.py -> build/lib.macosx-10.3-fat-2.5/MySQLdb
    running build_ext
    building '_mysql' extension
    gcc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -Dversion_info=( 1,2,2,'final',0 ) -D__version__=1. 2.2 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framewor k/Versions/2.5/include/python2.5 -c _mysql.c -o build/temp.macosx-10.3-fat-2.5/_mysql.o -g -Os -arch i386 -fno-common -D_P1003_1B_VISI BLE -DSIGNAL_WITH_VI O_CLOSE -DSIGNALS_DONT_B REAK_READ -DIGNORE_SIGHUP_ SIGQUIT -DDONT_DECLARE_C XA_PURE_VIRTUAL
    unable to execute gcc: No such file or directory
    error: command 'gcc' failed with exit status 1"
    Please suggest me what to do and how to go further....
    Thank You in advance for Your suggestion and help me.
    Warm Regards,
    Srinivas.
  • cnivas
    New Member
    • Feb 2009
    • 8

    #2
    Hi,

    Follow the steps to connect the MySQL database using Python:

    1) first download the mysql-python 1.2.2 from sourceforge.net

    2)modify the setup_posix.py line numbers:29,35

    from mysql_config.pa th="mysql_confi g"

    to

    mysql_config.pa th = "/usr/local/mysql/bin/mysql_config"

    3) save the file and now go to terminal

    admin:~admin$ sudo python setup.py install

    if u get gcc error then download the gcc from xcode tools
    or else u have mac cds with u. In that keep 2nd cd in the disk and install the xcode tools from it.

    4) please download the pyshell from sourceforge.net here is the link....

    Free, secure and fast downloads from the largest Open Source applications and software directory - SourceForge.net


    5) copy the pyshell from downloaded to Library->Frameworks->Python.Framewo rk->paste it.

    6) Open the pyshell.py and close it.

    7) now do the following step:

    admin:~admin$ sudo python setup.py install

    u will not get any gcc error.

    8) open the idle from Python 2.5 or 2.6 not the python launcher.......

    >>> import MySQLdb
    >>>

    u will get this it means MySQLdb was connected....

    Keep enjoying.......

    Comment

    Working...