无法连接到MySQL DB。找不到错误mysql.connector

时间:2019-04-25 21:50:49

标签: mysql python-3.x

我在Mac OS Mojave上 我无法使用Python3.7从本地(在我的机器中)MySQL DB中读取表数据 python非常新,所以我下载了Python3.7,然后pip安装mysql连接器。 但是,当我在脚本中导入mysql.connector时,我总是收到错误消息

我在运行ubuntu的服务器上安装了相同的pip,并且能够获取数据。在Mac中,请遵循相同的过程,但此过程无效。

如果我从IDLE运行import mysql.connector并运行相同的文件,它运行得很好。 但是,当我通过终端运行文件时,它给我一个错误。 到目前为止,我已经添加/更新了env以包括mysql连接器。 我不确定在这里我真的能做什么 寻找帮助

Traceback (most recent call last):
  File "compare_vion_csc_with_cmdb.py", line 1, in <module>
    import mysql.connector
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mysql/connector/__init__.py", line 42, in <module>
    from .connection import MySQLConnection
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mysql/connector/connection.py", line 50, in <module>
    from .network import MySQLUnixSocket, MySQLTCPSocket
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mysql/connector/network.py", line 33, in <module>
    import socket
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 52, in <module>
    import os, sys, io, selectors
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/selectors.py", line 12, in <module>
    import select
  File "/Users/skarki/Desktop/Python/Scripts/select.py", line 3, in <module>
    mydb = mysql.connector.connect(
AttributeError: module 'mysql' has no attribute 'connector'

0 个答案:

没有答案