gpt4 book ai didi

python - Six.moves 中的关键错误返回 sys.modules[fullname]

转载 作者:行者123 更新时间:2023-12-02 06:58:49 24 4
gpt4 key购买 nike

我正在尝试组合一个 Azure 函数以在 HTTP 触发器上运行。我的问题是,每当我运行该函数时,我都会从六个模块中收到一个关键错误异常。导入 pandas 时似乎会调用它,我不明白为什么。这是回溯:

Exception has occurred: KeyError
'six.moves'
File "/usr/local/Cellar/azure-functions-core-tools@3/3.0.3388/workers/python/3.7/OSX/X64/six.py", line 198, in load_module
return sys.modules[fullname]
File "/Users/benjaminhack/Desktop/GenesisAnalytics/Sentiment Analysis/Pipleines/functions/HttpTrigger1/__init__.py", line 2, in <module>
import pandas as pd
File "/usr/local/Cellar/azure-functions-core-tools@3/3.0.3388/workers/python/3.7/OSX/X64/azure_functions_worker/loader.py", line 76, in load_function
mod = importlib.import_module(fullmodname)
File "/usr/local/Cellar/azure-functions-core-tools@3/3.0.3388/workers/python/3.7/OSX/X64/azure_functions_worker/utils/wrappers.py", line 32, in call
return func(*args, **kwargs)
File "/usr/local/Cellar/azure-functions-core-tools@3/3.0.3388/workers/python/3.7/OSX/X64/azure_functions_worker/dispatcher.py", line 275, in _handle__function_load_request
func_request.metadata.entry_point)
File "/usr/local/Cellar/azure-functions-core-tools@3/3.0.3388/workers/python/3.7/OSX/X64/azure_functions_worker/dispatcher.py", line 242, in _dispatch_grpc_request
resp = await request_handler(request)
File "/usr/local/Cellar/azure-functions-core-tools@3/3.0.3388/workers/python/3.7/OSX/X64/azure_functions_worker/main.py", line 48, in main
args.host, args.port, args.worker_id, args.request_id))
File "/usr/local/Cellar/azure-functions-core-tools@3/3.0.3388/workers/python/3.7/OSX/X64/worker.py", line 86, in <module>
main.main()

该代码应该在 HTTP 触发器上运行一个函数,该函数使用 pandas。函数的 __init__.py 中的以下代码片段包含发生错误的导入语句:

import logging
import pandas as pd
import azure.functions as func

from .scraper import total_scrape
from .cleaning_analysis import clean_tweets, run_sentiment_analysis

def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')

### SCRAPE ###
logging.info("Initiating scrape")
df = total_scrape()
logging.info("Scraping complete")
logging.info("Shape: {}".format(df.shape))

### CLEAN ###

df = clean_tweets(df)

logging.info("Cleaning complete")

### ANALYSIS ###
df = run_sentiment_analysis(df)
logging.info("Sentiment Analysis completed")

return func.HttpResponse(f"{df.info}")

任何帮助将不胜感激。谢谢!

最佳答案

事实证明我的问题是由本地环境配置不当引起的。重做虚拟环境后,它自己整理得很好。

关于python - Six.moves 中的关键错误返回 sys.modules[fullname],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66902056/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com