Python libraries import error

RSN 15 Reputation points
2024-01-09T12:54:41.15+00:00

I am fairly new to using python notebooks on Azure AI ML Studio. Facing issues with import statements, for example

from langchain.document_loaders import PyPDFLoader

gives error - ModuleNotFoundError: No module named 'langchain'

Version of Python: 3.8.5

output of "pip list"

...

langchain 0.1.0

langchain-community 0.0.10

langchain-core 0.1.8

....

What am I missing here?

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,332 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Azar 29,520 Reputation points MVP Volunteer Moderator
    2024-01-09T13:07:31.3733333+00:00

    Hi '
    RSN

    Let me give you a few troubleshoots

    Firstly verify that you are using the correct Python environment in Azure AI ML Studio. Sometimes, there might be multiple environments, and the package may not be installed in the active environment.

    also heck the Python version and make sure it matches with the version for which you installed the langchain library.

    Try restarting the Python kernel. Try restarting the kernel in your Jupyter notebook or script.

    Ensure that the directory containing the langchain library is in the Python path. You can print the sys.path variable in your notebook to see the current paths.

    pythonCopy code
    import sys
    print(sys.path)
    
    

    finally confirm that the langchain library is installed in the correct Python environment. You can use the following command to check installed packages:

    pythonCopy code
    !pip list
    

    Verify that langchain is listed in the output.

    If this helps kindly accept the answer thanks much.

    0 comments No comments

  2. VasaviLankipalle-MSFT 18,676 Reputation points Moderator
    2024-01-10T23:42:57.3633333+00:00

    Hello @RSN , thanks for sharing the reference documents. As per the blog, looks like the author have used these versions:

    langchain==0.0.240

    openai==0.27.8

    I would suggest you to either raise a concern directly under the respective blog or here under the github issues: https://github.com/denisa-ms/azure-data-and-ai-examples/issues

    Here is the github sample, check the requirements: https://github.com/denisa-ms/azure-data-and-ai-examples/blob/master/openai/app_indexer.py

    I hope this helps.

    Regards, Vasavi

    -Please kindly accept the answer and vote 'yes' if you feel helpful to support the community, thanks.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.