gpt4 book ai didi

python - Azure FUnctions Enum RpcLogCategory 内的 Pinecone 没有为名称 'User' 定义值

转载 作者:行者123 更新时间:2023-12-03 03:22:36 25 4
gpt4 key购买 nike

我使用 Python 3.10 和 Azure Function Core Tools 4.0 使用 Python 创建了一个 Azure Function,其中明确表示要使用 Python 3.10 和 3.11(仍处于预览状态)。

我的代码实际上什么都没有,只是import pinecone破坏了代码。

    import pinecone
import logging
import azure.functions as func

def main(req: func.HttpRequest) -> func.HttpResponse:
return func.HttpResponse(f"Hello World")

VS Code 控制台显示了所有这些:

    createPineConeIndex: [GET,POST] http://localhost:7071/createPineConeIndex

For detailed output, run func with --verbose flag.
[2023-07-03T13:41:46.389Z] Worker process started and initialized.
[2023-07-03T13:41:49.571Z] Host lock lease acquired by instance ID '000000000000000000000000C65794F3'.
[2023-07-03T13:41:50.096Z] Worker failed to load function: 'createPineConeIndex' with functionId: '30b6cdec-555d-40ea-88c5-434896f07082'.
[2023-07-03T13:41:50.097Z] Result: Failure
Exception: ValueError: Enum RpcLogCategory has no value defined for name 'User'
Stack: File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.10/WINDOWS/X64\azure_functions_worker\dispatcher.py", line 380, in _handle__function_load_request
func = loader.load_function(
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.10/WINDOWS/X64\azure_functions_worker\utils\wrappers.py", line 44, in call
return func(*args, **kwargs)
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.10/WINDOWS/X64\azure_functions_worker\loader.py", line 132, in load_function
mod = importlib.import_module(fullmodname)
File "C:\Users\xx\anaconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Users\xx\repos\yy\createPineConeIndex\__init__.py", line 5, in <module>
from chromadb.config import Settings
File "c:\Users\xx\repos\yy\.venv\lib\site-packages\chromadb\__init__.py", line 6, in <module>
from chromadb.api import API
File "c:\Users\xx\repos\yy\.venv\lib\site-packages\chromadb\api\__init__.py", line 3, in <module>
import pandas as pd
File "c:\Users\xx\repos\yy\.venv\lib\site-packages\pandas\__init__.py", line 48, in <module>
from pandas.core.api import (
File "c:\Users\xx\repos\yy\.venv\lib\site-packages\pandas\core\api.py", line 27, in <module>
from pandas.core.arrays import Categorical
File "c:\Users\xx\repos\yy\.venv\lib\site-packages\pandas\core\arrays\__init__.py", line 1, in <module>
from pandas.core.arrays.arrow import ArrowExtensionArray
File "c:\Users\xx\repos\yy\.venv\lib\site-packages\pandas\core\arrays\arrow\__init__.py", line 1, in <module>
from pandas.core.arrays.arrow.array import ArrowExtensionArray
File "c:\Users\xx\repos\yy\.venv\lib\site-packages\pandas\core\arrays\arrow\array.py", line 60, in <module>
from pandas.core.arraylike import OpsMixin
File "c:\Users\xx\repos\yy\.venv\lib\site-packages\pandas\core\arraylike.py", line 21, in <module>
from pandas.core.ops.common import unpack_zerodim_and_defer
File "c:\Users\xx\repos\yy\.venv\lib\site-packages\pandas\core\ops\__init__.py", line 38, in <module>
from pandas.core.ops.array_ops import (
File "c:\Users\xx\repos\yy\.venv\lib\site-packages\pandas\core\ops\array_ops.py", line 57, in <module>
from pandas.core.computation import expressions
File "c:\Users\xx\repos\yy\.venv\lib\site-packages\pandas\core\computation\expressions.py", line 20, in <module>
from pandas.core.computation.check import NUMEXPR_INSTALLED
File "c:\Users\xx\repos\yy\.venv\lib\site-packages\pandas\core\computation\check.py", line 5, in <module>
ne = import_optional_dependency("numexpr", errors="warn")
File "c:\Users\xx\repos\yy\.venv\lib\site-packages\pandas\compat\_optional.py", line 142, in import_optional_dependency
module = importlib.import_module(name)
File "C:\Users\xx\anaconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "c:\Users\xx\repos\yy\.venv\lib\site-packages\numexpr\__init__.py", line 44, in <module>
nthreads = _init_num_threads()
File "c:\Users\xx\repos\yy\.venv\lib\site-packages\numexpr\utils.py", line 160, in _init_num_threads
log.info('NumExpr defaulting to %d threads.'%n_cores)
File "C:\Users\xx\anaconda3\lib\logging\__init__.py", line 1477, in info
self._log(INFO, msg, args, **kwargs)
File "C:\Users\xx\anaconda3\lib\logging\__init__.py", line 1624, in _log
self.handle(record)
File "C:\Users\xx\anaconda3\lib\logging\__init__.py", line 1634, in handle
self.callHandlers(record)
File "C:\Users\xx\anaconda3\lib\logging\__init__.py", line 1696, in callHandlers
hdlr.handle(record)
File "C:\Users\xx\anaconda3\lib\logging\__init__.py", line 968, in handle
self.emit(record)
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.10/WINDOWS/X64\azure_functions_worker\dispatcher.py", line 821, in emit
Dispatcher.current.on_logging(record, msg)
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.10/WINDOWS/X64\azure_functions_worker\dispatcher.py", line 208, in on_logging
log_category = protos.RpcLog.RpcLogCategory.Value('User')
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.10/WINDOWS/X64\google\protobuf\internal\enum_type_wrapper.py", line 73, in Value
raise ValueError('Enum {} has no value defined for name {!r}'.format(
.

如果我删除导入松果,错误就会消失

需求.txt

azure-functions
langchain
pinecone-client
#azure-storage-blob
openai
pyodbc
azure-identity
azure-keyvault-secrets
pydantic

最佳答案

我尝试通过在我的requirements.txt和init.py中导入pinecone来运行python azure函数。当我在解释器中使用 Python 3.10.11 venvPython 3.10.11 运行该函数时,它在我的 VS Code 本地成功运行。请参阅以下内容:-

我的要求.txt:-

azure-functions
langchain
pinecone-client
#azure-storage-blob
openai
pyodbc
azure-identity
azure-keyvault-secrets
pydantic

init.py:-

import logging

import azure.functions as func

import pinecone


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

name = req.params.get('name')
if not name:
try:
req_body = req.get_json()
except ValueError:
pass
else:
name = req_body.get('name')

if name:
return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
else:
return func.HttpResponse(
"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
status_code=200
)

Python 3.10.11 venv

enter image description here

enter image description here

确保您使用 Python 3.10 venv 作为解释器,如下所示:-

enter image description here

Python 3.10.11

enter image description here

在您的错误代码中,错误似乎与 chormabd 相关,chromabd 在 Python 3.10 上运行时存在一些问题,请参阅此 git hub issue对此发表评论。

关于python - Azure FUnctions Enum RpcLogCategory 内的 Pinecone 没有为名称 'User' 定义值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76605471/

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