[英]getting error ModuleNotFoundError: No module named 'mysql' when i have installed it
Hi all I have install mysql using大家好,我已经安装了 mysql 使用
pip3 install mysql
and I can see it in the pip3 list, but when I run the python app I am getting a error我可以在 pip3 列表中看到它,但是当我运行 python 应用程序时出现错误
ModuleNotFoundError: No module named 'mysql'
ModuleNotFoundError:没有名为“mysql”的模块
Not sure what the issue is, here is the code I am using to see if it might be something the code:不确定问题是什么,这是我用来查看它是否可能是代码的代码:
import urllib.parse
import requests
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="*******",
database="flightdata"
)
mycursor = mydb.cursor()
main_api = 'https://www.sydneyairport.com.au/_a/flights/?query=&flightType=departure&terminalType=domestic&date=2019-11-10&sortColumn=scheduled_time&ascending=true&showAll=true'
address = 'lhr'
url = main_api + urllib.parse.urlencode({address: address})
response_data = requests.get(url).json()
for element in response_data['flightData']:
flight_id = element['id']
airline = element['airline']
destination = element['destinations']
flightNumbers = element['flightNumbers']
scheduledTime = element['scheduledTime']
estimatedTime = element['estimatedTime']
scheduledDate = element['scheduledDate']
latestTime = element['latestTime']
status = element['status']
statusColor = element['statusColor']
sql = "INSERT INTO flightinfo (id, airline, destinations, flightNumbers, scheduledTime, estimatedTime, scheduledDate, latestTime, status, statusColor ) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s))"
val = [
(flight_id, airline, destination, flightNumbers, scheduledTime, estimatedTime, estimatedTime, scheduledDate, latestTime, status, statusColor),
]
mycursor.executemany(sql, val)
mydb.commit()
print(mycursor.rowcount, "was inserted.")
# print(airline, destination, flightNumbers, status, statusColor)
Try to install尝试安装
pip install mysql-connector-python mysql-connector-python
Or或者
pip install mysql-connector-python --allow-external mysql-connector-python
Or或者
pip install mysql-connector
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.