win7 下使用文中的方法安装mysql驱动失败, 换成了easy_install.exe pymysql3 安装的。
Topic source用easy_install.exe pymysql3 安装之后,并不能 import mysql.connector这个啊? ImportError: No module named 'mysql' 你没遇到这个情况吗?
换了驱动包, 里面相应的代码当然要跟着改成对应驱动包的代码, 在廖老师的代码基础上换掉导入驱动包和创建数据库连接代码就OK了。
import pymysql
conn = pymysql.connect(user='root', passwd='', host='localhost', port=3306, db='test')
其它的代码都一样,里面实现的方法也都差不多。
用你的方法在IDLE可以运行,一切正常,但是在.py文件中import pymysql 却报错
Traceback (most recent call last):
File "C:/Users/Administrator/python_scripts2/mysqlto203.py", line 1, in <module>
import pymysql
ImportError: No module named 'pymysql'
这会是什么原因呢?
- 1
一雷叔一
使用文中安装方法: pip install mysql-connector-python --allow-external mysql-connector-python
报错如下: Could not find a version that satisfies the requirement mysql-connector-python (from versions: ) No matching distribution found for mysql-connector-python