1

I created an Azure Function in Python, with Python 3.10 and Azure Function Core Tools 4.0 which clearly says to use Python 3.10 and 3.11 Is still on preview.

My code is literally nothing, just the import pinecone breaks the code.

    import pinecone
    import logging
    import azure.functions as func
    
    def main(req: func.HttpRequest) -> func.HttpResponse:    
        return func.HttpResponse(f"Hello World")

The vs code console shows all of this:

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

If I remove the import pinecone, the error disappears

requirements.txt

azure-functions
langchain
pinecone-client
#azure-storage-blob
openai
pyodbc
azure-identity
azure-keyvault-secrets
pydantic
Luis Valencia
  • 32,619
  • 93
  • 286
  • 506

1 Answers1

0

I tried running python azure function by importing pinecone in my requirements.txt and my init.py. It worked sucessfully locally in my VS Code when I used Python 3.10.11 venv and Python 3.10.11 in the interpretor to run the function. Refer below:-

My requirements.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

Make sure you use Python 3.10 venv as an interpretor like below:-

enter image description here

Python 3.10.11

enter image description here

In your error code the error seems to be with chormabd chromabd has some issues when it runs on Python 3.10 refer this git hub issue comments on the same.

SiddheshDesai
  • 3,668
  • 1
  • 2
  • 11