在学习python3操作mysql中遇到问题,代码入下:
import mysql.connector #创建mysql链接 conn = mysql.connector.connect(user='root',password='root',database='python',use_unicode=True) cursor = conn.cursor() #创建user表 #cursor.execute('create table user_test(user_id varchar(20) primary key,user_name varchar(20))') #插入记录 cursor.execute('insert into user_test(user_id,user_name) values(%s,%s)',['2','Jerry']) cursor.rowcount #提交事务 conn.commit() cursor.close()
运行时提示错误:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "mysql.py", line 3, in <module>
import mysql.connector
File "D:\python\mysql.py", line 3, in <module>
import mysql.connector
ImportError: No module named 'mysql.connector'; 'mysql' is not a package
File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "mysql.py", line 3, in <module>
import mysql.connector
File "D:\python\mysql.py", line 3, in <module>
import mysql.connector
ImportError: No module named 'mysql.connector'; 'mysql' is not a package
原因竟然是因为我写的测试文件的名称是 msyql.py 和已有的包mysql重名了,谨记。
参考:http://stackoverflow.com/questions/16055274/python-3-mysql-connector-frozen-import-lib
相关推荐
基于mysql.connector的数据库工具类,自行按业务修改啊
mysql-connector-python-2.1.7.tar.gz
mysql-connector-python,mysql开发连接依赖包!!!!!!!!!!!!!!
mysql-connector-python-2.1.6.zip, 解压后cd到安装目录,python setup.py install 即可, python命令行下 import mysql.connector 检验是否安装成功
mysql-connector-python-8.0.19-windows-x86-64bit,官网下载无改动。 MD5: 24551d3720abe8320cffd9d9c59f265c
Windows下利用mysql-connector-python让Python连接MYSQL
python连接mysql模块mysql-connector-python-2.1.1.tar.gz
图书信息管理系统python+mysql.zip
django,liunx下mysql数据库接口MySQL-python-1.2.3.tar.gz
1.安装python和mysql 这里就不多介绍了,很简单 2.安装setuptools ...3.下载编译版本 MySQL-python-1.2.3.win-amd64-py2.7.exe 双击安装 4.可以测试了 5.如果出错了,注意看下提示什么错误 直接解压就可以了~
mysql-connector-python-async 基于 2.0.2 的 MySQL Python 连接器,对 asyncio 进行了一些更改。 大多数示例来自 mysql-connector-python,针对异步访问进行了修改。 基本示例: import asyncio import mysql_...
mysql connector python 里面包含了2.7,3.3,3.4 python 已经出到3.5 但是 mysql链接包只出了3.4
MariaDB Connector/Python(mariadb-connector-python-1.0.7.zip)
MySQL-python-1.2.3.win32-py2.7.msi
安装mysql-connector-python 解压,运行python setup.py install python -c 'import mysql.connector'检验是否安装成功。
MySQL-python-1.2.3.win32-py2.7.exe MySQL-python-1.2.3.win-amd64-py2.7.exe
自己用VC++6.0编译的 MySQL-python,需要 MySQL-5.1.34 的 libMySQL.dll 和Python2.6的“Set”有点兼容性问题,自己照着改一下: http://sourceforge.net/forum/message.php?msg_id=5808948 1)__init__.py 删除 ...
windows linux 平台下的python27源码,以及python27_d.lib python27.lib python27_d.dll python27.dll。
MySQL python-1.2.2.win32-py2.6.rar python 连接 mysql用module MySQL python-1.2.2.win32-py2.6.rar python 连接 mysql用module
MySQL-python-1.2.3