Search code examples
visual-studio-codeimporterrorpylint

Unable to import 'azure.functions' pylint(import-error) [3,1] and Unable to import '__app__modules.library_finder' pylint(import-error) [4,1]


I'm trying to test out a serverless Python Chatbot API in Microsoft Azure, but when I follow online guide https://towardsdatascience.com/creating-a-serverless-python-chatbot-api-in-microsoft-azure-from-scratch-in-9-easy-steps-2f1913fc9581

it gives these error : Unable to import 'azure.functions' pylint(import-error) [3,1] Unable to import '__app__modules.library_finder' pylint(import-error) [4,1]

any idea how to resolve this?

Regards


Solution

  • This error is coming from pylint. It seems that the linter is not pointed to the .env and therefore cannot validate the azure package! To solve it, you can try this:

    In Visual Studio Code:

    • Locate the Python version in the status bar and click on it
    • Select the Azure workspace where your project resides
    • A list of Python versions show up for you. Pick the one that starts with ./.venv/ (In my case, it is: ./.venv/bin/python)
    • You might then get a popup saying the Linter pylint is not installed.
    • Click on Install button to install it and you should be good to go

    Hope this helps