2013年5月28日 星期二

Python筆記(4)

該學會的東西終究是逃不掉,紀錄一下python MySQLdb的配置方法
MySQL下載網站
安裝參考網站
在安裝參考網站有說需要先安裝 libmysqlclient-dev
否則回出現類似以下的Error:
Running setup.py egg_info for package MySQL-python
    sh: mysql_config: not found
    Traceback (most recent call last):
    File "", line 14, in 
    File "/home/vagrant/build/MySQL-python/setup.py", line 15, in 
        metadata, options = get_config()
    File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
    File "setup_posix.py", line 24, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    Complete output from command python setup.py egg_info:
    sh: mysql_config: not found

Traceback (most recent call last):

File "", line 14, in 

File "/home/vagrant/build/MySQL-python/setup.py", line 15, in 

    metadata, options = get_config()

File "setup_posix.py", line 43, in get_config

    libs = mysql_config("libs_r")

File "setup_posix.py", line 24, in mysql_config

    raise EnvironmentError("%s not found" % (mysql_config.path,))

EnvironmentError: mysql_config not found
在ubuntu下可用以下方法安裝
sudo apt-get install libmysqlclient-dev
緊接者只需要從官網下載MySQLdb,按照以下指令安裝
$ tar -zvxf MySQL-python-1.2.4b4
$ cd MySQL-python-1.2.4b4/
$ python setup.py build
$ sudo python setup.py install

沒有留言:

張貼留言