在Python中的mysql连接中出错

问题描述 投票:0回答:1

我像后端开发中的Python一样非常新。我想将python代码与数据库连接,所以我使用C:\Users\CCU-012\AppData\Local\Programs\Python\Python37\Scripts>python -m pip install mysql-connector-python安装了mysql-connector-python,但是当我在python代码中使用import mysql.connector时,出现错误Traceback (most recent call last): File "C:/Users/CCU-012/PycharmProjects/array/demo_mysql_connection.py", line 1, in <module> import mysql.connector ModuleNotFoundError: No module named 'mysql' this is the code and the error which I am getting

python mysql database connector
1个回答
0
投票

您已经在全球范围内安装了该模块,但是您的项目正在使用virtualenv(从PyCharm状态栏中的“ Python 3.7(数组)”文本中可以明显看出)。

将模块安装在virtualenv中;通过PyCharm做到这一点最简单的方法是打开Python控制台(底部的第4个选项卡),然后

pip install mysql-connector-python
© www.soinside.com 2019 - 2024. All rights reserved.