我正在尝试使用最新版本的cygwin,以便使用pandas和python3将Excel文件读入数据框。 我尝试使用pip导入或安装熊猫,但在运行过程中出现未找到模块错误。见下文。
我尝试使用不同的python包重新安装cygwin,在python3脚本文件夹中打开cmd并安装熊猫
import sys, os, re, json, argparse, logging
from datetime import datetime
#Version and Package checking - Python3, pip, pandas
if sys.version_info[0] < 3:
print("\nYou must have Python3 installed to use this tool.\n")
exit()
try:
import pip
except:
os.system("curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py")
os.system("python get-pip.py")
try:
import pandas as pd
#get rid of the SettingWithCopy warning from pandas when removing non word characters in EXCEL_AUDIT
#pd.set_option('mode.chained_assignment', None)
except:
os.system("pip install pandas --user")
#get rid of the SettingWithCopy warning from pandas when removing non word characters in EXCEL_AUDIT
import pandas as pd
pd.set_option('mode.chained_assignment', None)
import GXPLib
def EXCEL_READ(filename='5.4 NGT_Alarm Table_Rev0.1.xlsx'):
'''
Parameters: None
Actions: Reads pages 'Alarm Table' and 'Alert Table' from Excel file into a DataFrame for each page
Returns: DataFrame alarmsDF, DataFrame alertsDF
'''
logging.debug("Reading {} ...".format(filename))
ExcelFile = filename
try:
alarmsDF = pd.read_excel(
ExcelFile, 'Alarm Table', skiprows=1)
logging.debug("Alarms tab read")
alertsDF = pd.read_excel(
ExcelFile, 'Alert Table', skiprows=1)
logging.debug("Alerts tab read")
except:
logging.info("Failed to read file. Check file name, location and path.")
logging.info("Looking for {}".format(filename))
return
return alarmsDF, alertsDF
if __name__ == "__main__":
level = logging.INFO
if verbose == 1:
level = logging.DEBUG
format = "%(message)s"
handlers = [logging.FileHandler("alarmTable.log", "a+"), logging.StreamHandler()]
logging.basicConfig(level = level, format = format, handlers = handlers)
logging.info("******************************\n")
timestamp = datetime.now().strftime("%Y/%m/%d %H:%M:%S")
logging.info("alarmTable.log\nDate: {}".format(timestamp))
logging.info("\n******************************\n")
MAX = 28
alarmInfo, alertInfo = EXCEL_READ()
已满足要求:c:\ users \ mkoch \ appdata \ local \ programs \ python \ python37-32 \ lib \ site-packages中的熊猫(0.25.1) 已满足要求:pytz> = 2017.2,位于c:\ users \ mkoch \ appdata \ local \ programs \ python \ python37-32 \ lib \ site-packages(来自pandas)(2019.2) 已满足要求:c:\ users \ mkoch \ appdata \ local \ programs \ python \ python37-32 \ lib \ site-packages中的python-dateutil> = 2.6.1(来自熊猫)(2.8.0) 已经满足要求:numpy> = 1.13.3,位于c:\ users \ mkoch \ appdata \ local \ programs \ python \ python37-32 \ lib \ site-packages(来自熊猫)(1.17.0) 已经满足的要求:c:\ users \ mkoch \ appdata \ local \ programs \ python \ python37-32 \ lib \ site-packages中的6> = 1.5(来自python-dateutil> = 2.6.1-> pandas)(1.12。 0) 追溯(最近一次通话): 在第68行的文件“ alarmTable.py”中 将熊猫作为pd导入 ModuleNotFoundError:没有名为“ pandas”的模块