Langchain-huggingface
Hello, the langchain x huggingface framework seems perfect for what my team is trying to accomplish.I installed langchain-huggingface with pip3 in a venv and following this guide,Hugging Face x LangChain : A new partner packageI created a module like this but with a llma3 model:from langchain_huggingface import HuggingFacePipeline

llm = HuggingFacePipeline.from_model_id(
    model_id="microsoft/Phi-3-mini-4k-instruct",
    task="text-generation",
    pipeline_kwargs={
        "max_new_tokens": 100,
        "top_k": 50,
        "temperature": 0.1,
    },
)
llm.invoke("Hugging Face is")I get the following error when I try to run the script:ModuleNotFoundError: No module named ‘langchain_huggingface’I must be missing something or doing something very basic wrong.
2024-06-18T19:19:05Z
Hey@marky2376,I’m the author of the blog post, I’ll try to help you.I just retested the install and the import and both worked.“ModuleNotFoundError” are usually errors when you are not executing the code in the same environment as where you installed the library.Can you see langchain_huggingface in your!pip3 list?A second option is that you had a conflict in the installation of the library that you did not see ( the requirements of the libs include the latest version of tokenizers which might enter in conflict with other libs )
2024-06-18T19:42:43Z
I tried installing both inside and outside the venv,  here is the list for both:mneely@llmmaximus:/usr/projects/langface$ !pip3 listpip3 install langchain-huggingface listDefaulting to user installation because normal site-packages is not writeableRequirement already satisfied: langchain-huggingface in /usr/local/lib/python3.10/dist-packages (0.0.3)ERROR: Could not find a version that satisfies the requirement list (from versions: none)ERROR: No matching distribution found for list(.venv) mneely@llmmaximus:/usr/projects/langface$ !pip3 listpip3 install langchain-huggingface list list listCollecting langchain-huggingfaceUsing cached langchain_huggingface-0.0.3-py3-none-any.whl (17 kB)ERROR: Could not find a version that satisfies the requirement list (from versions: none)ERROR: No matching distribution found for list(.venv) mneely@llmmaximus:/usr/projects/langface$
2024-06-18T20:02:52Z
Alright, you have typos in your shared logs :marky2376:ERROR: No matching distribution found for listYou havepip3 install langchain-huggingface list list listOutside of the error from typo, I can see that:outside the env, the latest version ( 0.0.3 ) is installedmarky2376:Requirement already satisfied: langchain-huggingface in /usr/local/lib/python3.10/dist-packages (0.0.3)And inside it’s being reinstalled from cache because you most likely uninstalled before :marky2376:Using cached langchain_huggingface-0.0.3-py3-none-any.whl (17 kB)So, can you now give me the output of pip list ?Or alternatively do the following :enter pythontest the importjoffreythomas@MBP-de-joffrey  % python                        
Python 3.11.6 (main, Oct  2 2023, 13:45:54) [Clang 15.0.0 (clang-1500.0.40.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from langchain_huggingface import HuggingFacePipeline
>>>
2024-06-18T20:31:28Z
I’m just typing “!pip3 list” and that command is out putting “list” multiple times.  Maybe because I have attempted ~3 installs in my troubleshooting? I have never used that list command before so not sure.(.venv) mneely@llmmaximus:/usr/projects/langface$ python3Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linuxType “help”, “copyright”, “credits” or “license” for more information.from langchain_huggingface import HuggingFacePipelineTraceback (most recent call last):File “”, line 1, inModuleNotFoundError: No module named ‘langchain_huggingface’No, if I try outside the venv, I get what you have:from langchain_huggingface import HuggingFacePipelineSo I actually tried running my script again outside the venv, which I thought I had before.  It executes and finds the package.  (I get another error).What am I missing from being able to run this in a venv?
2024-06-19T16:23:27Z
Pip list is a command that will list all your installed packages.Alright, so outside the env it is installed.Once in, you can :Unintallpip uninstall langchain-huggingfaceRe-installpip install langchain-huggingfaceverify installationjoffreythomas@MBP-de-joffrey test % pip show langchain-huggingface
Name: langchain-huggingface
Version: 0.0.3
Summary: An integration package connecting Hugging Face and LangChain
Home-page: https://github.com/langchain-ai/langchain
Author: 
Author-email: 
License: MIT
Location: /opt/homebrew/lib/python3.11/site-packages
Requires: huggingface-hub, langchain-core, sentence-transformers, tokenizers, transformers
Required-by:If you have a problem during the installation process, please copy the log.
2024-09-06T19:04:30Z
Was having the same issue and scratched my head for a while, solution was pretty simple. The solution is to install jupyter from within the activated venv. So,activate environmentat any time) install all your required library like langchain_huggingfaceinstall jupyter notebookrun jupyter notebook
2024-09-06T19:21:16Z
gaston770:jupyterVery nice.  I ended up not using a venv at all for now.  I have gotten pretty far on my journey, and need to go back and reinstall all my packages within a venv.  Getting my application to run as a service is near impossible without it being in venv, so that’s my next major step.  Not using juputer, so I will have to figure it out as I go.