Install mysqldb on snow leopard

I am trying to get started on working with Python on Django I am by profession a PHP developer and have been told to set up django and python on my current apache and mysql setup however I am having trouble getting the Mysqldb module for python to work, I must of followed about 6 different set of instructions, I am running snow leopard and have mysql installed natively it is not part of MAMP or similar. Please can some tell me where I need to start and what steps I need to follew I would be most grateful.

Thanks


Asked by: Kelsey977 | Posted: 27-01-2022






Answer 1

On MAC OS X 10.6, Install the package as usual. The dynamic import error occurs because of wrong DYLD path. Export the path and open up a python terminal.

$ sudo python setup.py clean

$ sudo python setup.py build

$ sudo python setup.py install

$ export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH

$python

import MySQLdb

Now import MySQLdb should work fine.

You may also want to manually remove the build folder, before build and install. The clean command does not do a proper task of cleaning up the build files.

Answered by: Kevin985 | Posted: 28-02-2022



Answer 2

I'd recomend installing macports (latest svn trunk) and installing mysql from there.

sudo port install mysql5-server

Download the MySQL-python-1.2.2 source

make sure /opt/local/lib/mysql5/bin is in your path or edit site.cfg to include:

mysql_config = /opt/local/lib/mysql5/bin/mysql_config

Comment out line 38 of _mysql.c

// #define uint unsigned int

Then run:

sudo python setup.py install

should be all good.

Answered by: Miller918 | Posted: 28-02-2022



Answer 3

[Partial Answer]

You'll have more fun pulling out your teeth. MySQL/Django/Mac is a disaster. This is the farthest I've gotten:

Get MySQLDB 1.2.3 Go into that and modify setup_posix.py:

Change:

mysql_config.path = "mysql_config"

To (depending on the version number of your MySQL):

mysql_config.path = "/usr/local/mysql-5.1.34-osx10.5-x86_64/bin/mysql_config"

python setup.py build python setup.py install

Here's a good article

Answered by: Blake813 | Posted: 28-02-2022



Answer 4

First and foremost, make sure that XCode is installed. Without XCode, many pieces of the built-in Apache2 server important to developers are missing; most notably, the GNU Compiler Collection, which I would think to be requisite for MySQL bindings.

Answered by: Leonardo600 | Posted: 28-02-2022



Answer 5

One of the key things here is to make sure you're running both MySQL and the Python adaptor in 64 bit. The default Python 2.6.1 install on Snow Leopard is 64 bit so you must install MySQL in 64 bit and build the MySQLdb adapter in 64 bit.

  1. Make sure you have the latest Xcode installed
  2. Install 64-bit MySQL from DMG - http://dev.mysql.com/downloads/mirror.php?id=401941#mirrors
  3. Download MySQL-python-1.2.3 from http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3.tar.gz
  4. Extract and make the following edit to site.cfg:

    mysql_config = /usr/local/mysql/bin/mysql_config
    
  5. Then from your terminal run

    ARCHFLAGS="-arch x86_64" python setup.py build
    sudo python setup.py install
    

You should then open a Python shell and type:

import MySQLdb

If you don't get any errors you're golden.

Answered by: Daryl350 | Posted: 28-02-2022



Answer 6

  1. Xcode was installed.

  2. Follow these instructions for setting up apache/php/mysql:

    http://maestric.com/doc/mac/apache_php_mysql_snow_leopard

  3. I installed the free 32-bit version of EPD (this is optional but I wanted numpy/scipy).

  4. Make sure you have these lines in your ~/.profile (the second line is only if you installed EPD):

    export PATH=/usr/local/mysql/bin/:/usr/local/bin:/usr/local/sbin:$PATH
    export PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
    
  5. Downloaded mysqldb and run:

    python setup.py build
    
    sudo python setup.py install
    
  6. Install the official release of Django or web2py. Everything worked after that. You can try the "Writing Your First Django App, Part 1" to test it out where in settings.py use:

    DATABASE_ENGINE = 'mysql'           
    DATABASE_NAME = 'Django Polls'             
    DATABASE_USER = '*****'             
    DATABASE_PASSWORD = '*****'         
    DATABASE_HOST = '127.0.0.1'             
    DATABASE_PORT = '3306'             
    
  7. I also use Navicat Lite and Sequel Pro for working with MySQL.

  8. Pydev is a nice IDE to use with Django.

Answered by: Adelaide460 | Posted: 28-02-2022



Answer 7

  1. Install the newest 64bit DMG version of MySQL. Remember to backup your databases if you already have MySQL installed.
  2. enter this line in terminal:

    sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql

  3. Edit the file setup_posix in the mysql-python installation directory.

Change the line

mysql_config.path = "mysql_config"

to

mysql_config.path = "/usr/local/mysql/bin/mysql_config"
  1. Myslq-Python needs a 64bit Version of Python. The new Python 2.7 64bit version creates an alias in /usr/local/bin/python.
  2. Enter the following lines in the mysql-python folder

    sudo /usr/local/bin/python setup.py clean

    sudo ARCHFLAGS="-arch x86_64"

    sudo /usr/local/bin/python setup.py build

    sudo /usr/local/bin/python setup.py install

And finally try it out:

python
import MySQLdb

Answered by: Joyce193 | Posted: 28-02-2022



Answer 8

You could make your life a lot easier (especially on Lion) by just installing Mariadb instead:

http://mariadb.org/

It's a drop-in replacement for MySQL and is plug&play on OSX. The only thing you don't get is the MySQL system setting.

Answered by: Tara805 | Posted: 28-02-2022



Similar questions

python - Install MySQLdb on snow leopard without XCode

Is it possible to install the MySQLdb python module on Snow Leopard without XCode? I am not a member of the $99/year developer programs, so I do not have XCode.


mysql - Install MySQLdb python module

i want to install MySQLdb module for Python on Windows 7, but I get an error G:\python\python and mysql\MySQL-python-1.2.3b2\MySQL-python-1.2.3b2>setup.py Traceback (most recent call last): File "G:\python\python and mysql\MySQL-python-1.2.3b2\MySQL-python-1.2.3b2\set up.py", line 15, in <module> metadata, options = get_config() File "G:\python\python and mysql\MySQL-python-1.2.3b2\MySQL-p...


python - Install MySQLdb on snow leopard without XCode

Is it possible to install the MySQLdb python module on Snow Leopard without XCode? I am not a member of the $99/year developer programs, so I do not have XCode.


mysql - install python MySQLdb to python3 not python

i have Ubuntu and installed python3 since my script is written in it. Since I use MYSQL with MySQLdb, I installed apt-get install python-mysqldb however this installed MySQLdb to Python (which is 2.6 on Ubuntu) and not to Python3. How can I install MySQLdb for Python3 Should I use it at all or switch to PyMSQL Sorry, I have just started working with Python...


python - Install MySQLdb on a Mac

I have Python 32 bits, I installed MySQL Community server 32 bits and I'm trying to install MySQLdb for Python. I run easy_install mysql-python and I have this error > easy_install mysql-python Searching for mysql-python Reading http://pypi.python.org/simple/mysql-python/ Reading http://sourceforge.net/projects/mysql-python/ Reading http://sourceforge.net/proj...


python - install MySQLdb to run in Pydev on Mac OS X 10.8

I had been stuck in some incompatible conflicts while trying to install mysql-python in Mac OS X 10.8 for a few days. After looking at some forums I found the solution to force Python run in 32 bit because mysql-python (MySQLdb) only has the 32 bit version: export VERSIONER_PYTHON_PREFER_32_BIT=yes That command helped to run MySQLdb in Terminal well. However when I installed PyDev, and tried to...


How to install MySQLdb in Python 2.6 CentOS

I am getting this message when I use yum install mysql-python to install MySQLdb. Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.sin3.sg.voxel.net * extras: mirrors.sin3.sg.voxel.net * updates: mirrors.sin3.sg.voxel.net base | 3.7 kB 00:00 extras ...


python - How to Install MySQLdb in PyCharm, Windows

I am new to Python(I am using Python2.6) and Pycharm, but I need to use MySQLdb module to complete my task. I found How to install MySQLdb in Python 2.6 CentOS but I need it at Windows 7(64 bits) Is there any way to easily install this module using Pycharm? I am using Pycharm(3.1.1 profession...


python - How can I use Conda to install MySQLdb?

I've read several different explanation regarding how to install MySQLdb, but I'm not sure which case applies to me since my error message is different. My system can't seem to find MySQLdb. I installed pymysql, but i need to import MySQLdb to use procedures from that library. Thanks for your help. $ conda install MySQLdb Fetching package metadata: .... Error: No packages fo...


mysql - How do I install and use MySQLdb for Python 3 on Windows 10?

My various searches seem to come up with very old posts or a mention of how to do this under cygwin. I had python 3.5 installed and then installed Anaconda3. I have python 3.5 (Cpython) installed in my user directory. I tried changing the order of how things appear in my Windows Environment Variables path, so that I could try both the Anaconda version of Python and the other version of python that I have. Curr...


Unable to install mysqldb on python

I am trying to install mysqldb for python on my windows PC but come across this error: (Note I know I am using an outdated version of python but this is the version I need to use for now)


macos - python install on leopard

I'll admit I'm completely dumbed by python install. Can someone help me on how to install module I want to play with PyGame, PyOpenGL etc. So I install them, but I everytime I type "import pygame" error message shows up. here's my environment so far. In .bash_profile PATH=${PATH}:/System/Library/Frameworks/Python.framework/Versions/Current/bin Using easy_install PyO...


python - How can I install pyCurl?

I used libcurl with no problems and used pyCurl once in the past. Now i want to set it up on my machine and dev. However i have no idea how to do it. I rather not DL libcirl files and compile that along with pycurl, i want to know the simplest method. I have libcurl installed on my machine. I am on Windows. I tried DLing the sources and use pycurl setup script, but I had no luck.


python - where does django install in ubuntu

I am looking for the init.py file for django. I tried whereis and find, but I get a lot of dirs.


Install python 2.6 in CentOS

I have a shell that runs CentOS. For a project I'm doing, I need python 2.5+, but centOS is pretty dependent on 2.4. From what I've read, a number of things will break if you upgrade to 2.5. I want to install 2.5 separately from 2.4, but I'm not sure how to do it. So far I've downloaded the source tarball, untarred it, and did a ./configure --prefix=/opt which is where I want it to end ...


How to install 64-bit Python on Solaris?

I am trying to install Python 2.6 on Solaris by building the source on Solaris machine. I installed one this way and it appears that it is 32-bit. I downloaded some source tar ball as Linux or Unix for this purpose. Everything works well but I need 64-bit Python. I looked up the Python download site and there is no sepa...


macos - Install PyObjC on Python 2.6 on OS X 10.5?

OS X 10.5.8 came with Python 2.5, and had PyObjC already installed. I installed Python 2.6 from the python.org site, and PyObjC isn't there. I can't find a download to install PyObjC on my Python 2.6 install. Is checking out the PyObjC trunk and trying to build it my only choice? Will that work "out of the box"?


python - How to install numpy and scipy on Windows XP


python - How do I install SciPy on 64 bit Windows?

How do I install SciPy on my system? For the NumPy part (that SciPy depends on) there is actually an installer for 64 bit Windows: numpy-1.3.0.win-amd64-py2.6.msi (is direct download URL, 2310144 bytes). Running the SciPy superpack installer results in this message in a dialog box:...


What should I install in order to be able to use GTK in Python on Ubuntu?

In my source code I have: import gtk But when I run the script with python3 script.py command I get the following error. What package should I install to get it working? Edit: my bad. here is the error: ImportError: No module named gtk Edit2: Thanks for the answer, kaizer.se. But I'm still getting an error message. Take a look at the following...


python - How to install pycairo on osx?

I am trying to install the pycairo (Python bindings for the cairo graphics library) under OSX. I started with easy_install pycairo and got: Requested 'cairo >= 1.8.8' but version of cairo is 1.0.4 error: Setup script exited with Error: cairo...






Still can't find your answer? Check out these communities...



PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python



top