简体   繁体   English

收到错误 ModuleNotFoundError: No module named 'mysql' 当我安装它时

[英]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.

相关问题 ModuleNotFoundError:没有名为“pandas”的模块 - 当我已经安装了熊猫时 - ModuleNotFoundError: No module named 'pandas' - when I have pandas already installed ModuleNotFoundError:安装后没有名为“pgzrun”的模块? - ModuleNotFoundError: No module named 'pgzrun' when I have it installed? 我已经安装了 Anaconda 并且我也安装了 pygame,但仍然出现错误 ModuleNotFoundError: No module named 'pygame' - I have installed Anaconda and I have installed pygame as well, but still got an error ModuleNotFoundError: No module named 'pygame' 我不断收到错误“ModuleNotFoundError:我的 settings.py 文件中没有名为‘environ’的模块”。 我已经在我的 python shell 中安装了依赖项 - I keep getting the error "ModuleNotFoundError: No module named 'environ' in my settings.py file". I have installed the dependency in my python shell ModuleNotFoundError: 没有名为“unidecode”的模块,但我已经安装了该模块 - ModuleNotFoundError: No module named 'unidecode' yet I have the module installed 我一直收到“ModuleNotFoundError:没有名为‘error’的模块” - I kept getting "ModuleNotFoundError: No module named 'error'" 我安装了一个名为 Discord 的模块,在使用“import discord”时出现错误:“ModuleNotFoundError: No module named 'discord'” - I Installed a Module Called Discord and When Using “import discord” I Get the Error: “ModuleNotFoundError: No module named 'discord'” ModuleNotFoundError:即使我安装了功能工具,也没有名为“功能工具”的模块 - ModuleNotFoundError: No module named 'featuretools' even though I have installed featuretools ModuleNotFoundError:没有名为“magenta.protobuf”的模块,但我已经安装了它 - ModuleNotFoundError: No module named 'magenta.protobuf' but I have installed it 安装了virtualenv,但仍然出现“ ModuleNotFoundError:没有名为“ virtualenv”的模块”错误 - Installed virtualenv, but still getting “ModuleNotFoundError: No module named 'virtualenv'” error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM