大Pandas在cygwin内失败

2024-09-30 16:41:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用cygwin的最新版本,使用pandas和python3将excel文件读入数据帧。 我有一个尝试,除了导入或安装熊猫使用pip,但在运行过程中,我得到一个模块没有找到错误。见下文

我试过用不同的python包重新安装cygwin,在python3scripts文件夹中打开cmd并安装pandas

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()

已满足要求:pandas in c:\users\mkoch\appdata\local\programs\python37-32\lib\site包(0.25.1) 已满足要求:pytz>=c:\users\mkoch\appdata\local\programs\python37-32\lib\site包中的2017.2(来自pandas)(2019.2) 已满足要求:python dateutil>=2.6.1在c:\users\mkoch\appdata\local\programs\python37-32\lib\site包中(来自pandas)(2.8.0) 已满足要求:numpy>=1.13.3在c:\users\mkoch\appdata\local\programs\python37-32\lib\site包中(来自pandas)(1.17.0) 已满足要求:6>=c:\users\mkoch\appdata\local\programs\python\python37-32\lib\site包中的1.5(来自python dateutil>=2.6.1->;熊猫)(1.12.0) 回溯(最近一次呼叫): 文件“alarmTable.py”,第68行,in 作为pd导入 ModuleNotFoundError:没有名为“pandas”的模块


Tags: pipimportgtinfoformatpandasreadget