一开始用python做mysql的连接,打算用MysqlDb,但是安装的时候出现了报错。
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/7x/8t14gbrs5rg95xftbztw4rmh0000gn/T/pip-install-i9ix33gi/MySQL-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/private/var/folders/7x/8t14gbrs5rg95xftbztw4rmh0000gn/T/pip-install-i9ix33gi/MySQL-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
原因:
在 Python 3.x 版本后,ConfigParser.py 已经更名为 configparser.py 所以出错!
有两种解决办法:
解决方法1:
找到文件 configparser ,更名为旧版本的名称 ConfigParser
解决方法2:
干脆直接抛弃MysqlDB,转而使用PyMysql。
在mac下直接使用命令就可以安装了
pip3 install PyMySQL
解决Python MySQLdb安装错误
本文介绍了在Python中使用MySQLdb遇到的安装错误,并提供了两种解决方案。一种是修改ConfigParser的名称,另一种是更换为PyMySQL。对于使用Python 3.x的用户来说,由于模块名称更改,直接使用PyMySQL更为简便。
1429

被折叠的 条评论
为什么被折叠?



