Created
April 13, 2011 08:56
-
-
Save zeuxisoo/917222 to your computer and use it in GitHub Desktop.
MAMP + Python-MySQLdb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Goto http://dev.mysql.com/downloads/mysql/ | |
2. Select Platform: "Mac OS X" | |
3. Download mysql-5.5.11-osx10.6-x86.tar.gz | |
(Mac OS X ver. 10.6 (x86, 32-bit), Compressed TAR Archive) | |
4. Unzip it | |
5. Copy include folder into /Applications/MAMP/Library | |
6. Copy lib/* files into /Applications/MAMP/Library/lib | |
---- | |
1. Goto http://sourceforge.net/projects/mysql-python/ | |
2. Download MySQL-python-1.2.3.tar.gz | |
3. unzip it | |
---- | |
1. virtualenv --no-site-package test | |
2. cd test/bin | |
3. source activate | |
4. lipo -remove x86_64 ./python -output ./python | |
---- | |
1. export DYLD_LIBRARY_PATH=/Applications/MAMP/Library/lib | |
2. export ARCHFLAGS='-arch i386' | |
---- | |
1. cd MySQL-python-1.2.3 | |
2. vim setup_posix.py | |
3. search mysql_config.path | |
4. set the value to /Applications/MAMP/Library/bin/mysql_config | |
5. save and exit | |
6. python setup.py install | |
---- | |
import _mysql | |
db = _mysql.connect(unix_socket="/Applications/MAMP/tmp/mysql/mysql.sock",db="mysql",user="root",passwd="root") | |
db.query("select version()") | |
result = db.use_result() / result = db.store_result() | |
result.fetch_row() | |
result.fetch_row(result.num_rows()) | |
result.fetch_row() | |
result.data_seek(0) | |
result.fetch_row() | |
---- | |
If import _mysql Got Reason: image not found | |
try: | |
export DYLD_LIBRARY_PATH=/Applications/MAMP/Library/lib | |
export ARCHFLAGS='-arch i386' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
run:
python setup.py install
Show bugs:
python setup.py install Traceback (most recent call last): File "setup.py", line 13, in <module> from setup_posix import get_config File "/MyDatas/Environment/MySQL-python-1.2.5/setup_posix.py", line 2, in <module> from ConfigParser import SafeConfigParser ModuleNotFoundError: No module named 'ConfigParser'
Open file: setup_posix.py, you can see:
from ConfigParser import SafeConfigParser
Model ConfigParser not found.
=> change model: ConfigParser to configparser (Python 3.6)
Or run command to copy module:
sudo cp /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/configparser.py /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ConfigParser.py
=> You can review python version and fix some as above.
Run:
python setup.py install
The package MySQL-python installed.