Python下使用MySQL數據庫

在安裝MySQL之後和mysql-connector-c之後,安裝MySQLdb

sudo pip install setuptools; //Python標準的打包及分發工具
sudo pip install tokenize; 

問題1:python mysql_config: command not found
mysql_config命令未找到,進入用戶根目錄設置PATH

touch .bash_profile
// 編輯內容 PATH=$PATH:/usr/local/Cellar/mysql/5.7.21/bin
source .bash_profile

問題2:Running setup.py install for MySQL-python … error

Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-gkffZ3/MySQL-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-pQ0TCV-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-gkffZ3/MySQL-python/

解決:

brew install mysql-connector-c

安裝失敗可以使用pymysql

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章