安装python mysql(MySQLdb)驱动失败 No module named 'ConfigParser'

荒之凡Charon 2016-10-31 06:10:11
我新建的pyhton3 的 虚拟环境 python 的版本是python3.4
因为需要 安装 SQLAlchemy 但是我pip install 后 提示 需要安装MySQLdb 然后 我 pip isntall mysql-python 一下 有报错
Collecting mysql-python
Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-9vtb85ke/mysql-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/tmp/pip-build-9vtb85ke/mysql-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-9vtb85ke/mysql-python/
然后我 接着 安装 pip install ConfigParser 后

Requirement already satisfied (use --upgrade to upgrade): ConfigParser in /home/chenglong/pytest/flaskenv/lib/python3.4/site-packages
(flaskenv) chenglong@iZuf6fn1rjw3rff1afi0itZ:~/pytest/flasktest$ pip install mysql-python
Collecting mysql-python
Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-ny69mdyx/mysql-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/tmp/pip-build-ny69mdyx/mysql-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'

还是 No module named 'ConfigParser'
...全文
703 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
飞亚徐 2017-03-10
  • 打赏
  • 举报
回复
楼主你好,我在mac上安装mysql-python,是在虚拟环境中,然后也提示

接着安装了ConfigParser,再次安装mysql-python 还是一样的错误,我按照楼主的方法往下执行 一直不行啊 。
荒之凡Charon 2016-10-31
  • 打赏
  • 举报
回复
我根据 stackoverflow 的提示 应该先安装 apt-get install libmysqlclient-dev 然后 在 pip install mysql-python 结果 又报错 _mysql.c:29:20: fatal error: Python.h: No such file or directory #include "Python.h" ^ compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 然后 我 又 sudo apt-get install python-dev # for python2.x installs sudo apt-get install python3-dev # for python3.x installs 结果成功了

10,606

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 其他
社区管理员
  • 其他
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧