简体   繁体   English

ModuleNotFoundError:没有名为 'mysql'12 的模块

[英]ModuleNotFoundError: No module named 'mysql'12

I am running the following code but expected to get the records from the student table in test database.我正在运行以下代码,但希望从测试数据库中的学生表中获取记录。

Here is my code:这是我的代码:

import mysql.connector
word = input("Enter a word in English and press Enter: ")
con = mysql.connector.connect(
    user="root", 
    password = "root", 
    host="localhost", 
    database = "test"
)
cursor = con.cursor()
query = cursor.execute("SELECT * FROM student")
results = cursor.fetchall()
if results:
    for result in results:
        print(result[1])
else:
    print("We couldn't find any results about that.")

And here is the result:结果如下:

Traceback (most recent call last):
  File "g:/python learning/mysqlconnector.py", line 1, in <module>
    import mysql.connector
ModuleNotFoundError: No module named 'mysql'

try to use the command尝试使用命令

pip install mysql-connector

in terminal or cmd()在终端或 cmd()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ModuleNotFoundError: 没有名为“mysql”的模块 - ModuleNotFoundError: No module named 'mysql' Python ModuleNotFoundError:没有名为“ mysql”的模块 - Python ModuleNotFoundError: No module named 'mysql' Apache Spark - ModuleNotFoundError:没有名为“mysql”的模块 - Apache Spark - ModuleNotFoundError: No module named 'mysql' ModuleNotFoundError:没有名为“mysql.connector”的模块; - ModuleNotFoundError: No module named 'mysql.connector'; ModuleNotFoundError:没有名为“werkzeug.contrib”的模块(ODOO 12) - ModuleNotFoundError: No module named 'werkzeug.contrib' (ODOO 12) ModuleNotFoundError:即使安装了模块,也没有名为“mysql”的模块 - ModuleNotFoundError: No module named 'mysql' even when module is installed ModuleNotFoundError:没有安装 mysql-connector-python 的名为“mysql”的模块 - ModuleNotFoundError: No module named 'mysql' with mysql-connector-python already installed 无法导入 mysql.connector - ModuleNotFoundError: 没有名为“mysql”的模块 - Cannot import mysql.connector - ModuleNotFoundError: No module named 'mysql' ModuleNotFoundError:没有名为“mysql.connector”的模块; 'mysql' 不是 package - ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package 导入 mysql.connector ModuleNotFoundError: 没有名为“mysql”的模块 - import mysql.connector ModuleNotFoundError: No module named 'mysql'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM