module ‘pymysql‘ has no attribute ‘connect‘
No module has attribute connect pymysql
2023-09-11 14:14:27 时间
之前试试用python 连接 mysql ,用到了pymysql模块,程序如下:
-
import pymysql
-
-
connection = pymysql.connect(
'localhost',
'root',
'123456',
'python_opmysql')
-
-
-
sql =
"create table wee (name varchar(10), age int(2));"
-
-
cursor = connection.cursor()
-
-
cursor.execute(sql)
-
-
connection.commit()
-
connection.close()
然后报错了:
AttributeError: module 'pymysql' has no attribute 'connect'
找了十多分钟,,然后发现一个问题:
文件和模块重名了。。。(难怪自动联想也没弹出来,,,)
把文件名字改掉:
运行成功:
相关文章
- redhat 6安装python 3.7.4报错ModuleNotFoundError: No module named '_ctypes' make: *** [install] Error 1
- 小程序解决git代码管理的no merge base found 问题
- no module named _lzma
- module ‘importlib._bootstrap‘ has no attribute ‘SourceFileLoader‘
- AttributeError: module ‘torchtext.data‘ has no attribute ‘Field‘/AttributeError: module ‘torchtext.d
- No supported encrypter found. The cipher and / or key length are invalid.
- centos6 python 安装 sqlite 解决 No module named ‘_sqlite3′
- 挂载完根文件系统后停止在提示INIT: no more processes left in this runlevel处如何处理?
- No module named PIL
- ImportError: No module named Crypto.PublicKey
- 【Python】AttributeError: module 'enum' has no attribute 'Enum'
- No module named ‘yaml‘解决方案
- AttributeError: module 'pip' has no attribute 'main'
- 【hacker的错误集】AttributeError:module ‘requests‘ has no attribute ‘get‘
- python AttributeError: module ‘lib‘ has no attribute ‘X509_V_FLAG_CB_ISSUER_CHECK‘
- 解决python “No module named pip”
- 为树莓派安装pip3及setuptools已安装仍报错No module named ‘setuptools‘的解决
- [AWS] Unable to import module 'lambda_function': No module named 'requests'
- 【AI学习笔记】ModuleNotFoundError: No module named ‘keras.layers.embeddings‘
- 【AI学习笔记】AttributeError: module ‘keras.preprocessing.sequence‘ has no attribute ‘pad_sequences‘
- 【Python】Pycharm报错:AttributeError: ‘HTMLParser‘ object has no attribute ‘unescape‘
- AttributeError: module 'torch._C' has no attribute '_cuda_setDevice'(在python命令后面加上 --gpu_ids -1)