Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'langchain.embeddings.base' #82

Open
mckinlec opened this issue Sep 19, 2023 · 1 comment
Open

Comments

@mckinlec
Copy link

I'm getting the following error even after running conda install -c conda-forge langchain

chatdocs download ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ /mnt/i/chatdocs/chatdocs/chatdocs/main.py:23 in download │ │ │ │ 20 │ │ 21 @app.command() │ │ 22 def download(config: ConfigPath = None): │ │ ❱ 23 │ from .download import download │ │ 24 │ │ │ 25 │ config = get_config(config) │ │ 26 │ download(config=config) │ │ │ │ ╭─── locals ────╮ │ │ │ config = None │ │ │ ╰───────────────╯ │ │ │ │ /mnt/i/chatdocs/chatdocs/chatdocs/download.py:3 in <module> │ │ │ │ 1 from typing import Any, Dict │ │ 2 │ │ ❱ 3 from .embeddings import get_embeddings │ │ 4 from .llms import get_llm │ │ 5 │ │ 6 │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ __builtins__ = { │ │ │ │ │ '__name__': 'builtins', │ │ │ │ │ '__doc__': 'Built-in functions, exceptions, and other │ │ │ │ objects.\n\nNoteworthy: None is the nil'+46, │ │
│ │ │ 'package': '', │ │
│ │ │ 'loader': <class '_frozen_importlib.BuiltinImporter'>, │ │
│ │ │ 'spec': ModuleSpec(name='builtins', loader=<class │ │
│ │ '_frozen_importlib.BuiltinImporter'>, origin='built-in'), │ │
│ │ │ 'build_class': , │ │
│ │ │ 'import': , │ │
│ │ │ 'abs': , │ │
│ │ │ 'all': , │ │
│ │ │ 'any': , │ │
│ │ │ ... +145 │ │
│ │ } │ │
│ │ cached = '/mnt/i/chatdocs/chatdocs/chatdocs/pycache/download.cpython-310.pyc' │ │
│ │ doc = None │ │
│ │ file = '/mnt/i/chatdocs/chatdocs/chatdocs/download.py' │ │
│ │ loader = <_frozen_importlib_external.SourceFileLoader object at 0x7f4b7646ad10> │ │
│ │ name = 'chatdocs.download' │ │
│ │ package = 'chatdocs' │ │
│ │ spec = ModuleSpec(name='chatdocs.download', │ │
│ │ loader=<_frozen_importlib_external.SourceFileLoader object at │ │
│ │ 0x7f4b7646ad10>, origin='/mnt/i/chatdocs/chatdocs/chatdocs/download.py') │ │
│ │ Any = typing.Any │ │
│ │ Dict = typing.Dict │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /mnt/i/chatdocs/chatdocs/chatdocs/embeddings.py:4 in │
│ │
│ 1 from typing import Any, Dict │
│ 2 │
│ 3 from langchain.embeddings import HuggingFaceInstructEmbeddings, HuggingFaceEmbeddings │
│ ❱ 4 from langchain.embeddings.base import Embeddings │
│ 5 │
│ 6 │
│ 7 def get_embeddings(config: Dict[str, Any]) -> Embeddings: │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ builtins = { │ │
│ │ │ 'name': 'builtins', │ │
│ │ │ 'doc': 'Built-in functions, exceptions, and other │ │
│ │ objects.\n\nNoteworthy: None is the nil'+46, │ │ │ │ │ '__package__': '', │ │ │ │ │ '__loader__': <class │ │ │ │ '_frozen_importlib.BuiltinImporter'>, │ │ │ │ │ '__spec__': ModuleSpec(name='builtins', loader=<class │ │ │ │ '_frozen_importlib.BuiltinImporter'>, origin='built-in'), │ │ │ │ │ '__build_class__': <built-in function __build_class__>, │ │ │ │ │ '__import__': <built-in function __import__>, │ │ │ │ │ 'abs': <built-in function abs>, │ │ │ │ │ 'all': <built-in function all>, │ │ │ │ │ 'any': <built-in function any>, │ │ │ │ │ ... +145 │ │ │ │ } │ │ │ │ __cached__ = '/mnt/i/chatdocs/chatdocs/chatdocs/__pycache__/embeddings.c… │ │ │ │ __doc__ = None │ │ │ │ __file__ = '/mnt/i/chatdocs/chatdocs/chatdocs/embeddings.py' │ │ │ │ __loader__ = <_frozen_importlib_external.SourceFileLoader object at │ │ │ │ 0x7f4b7646ae90> │ │ │ │ __name__ = 'chatdocs.embeddings' │ │ │ │ __package__ = 'chatdocs' │ │ │ │ __spec__ = ModuleSpec(name='chatdocs.embeddings', │ │ │ │ loader=<_frozen_importlib_external.SourceFileLoader object │ │ │ │ at 0x7f4b7646ae90>, │ │ │ │ origin='/mnt/i/chatdocs/chatdocs/chatdocs/embeddings.py') │ │ │ │ Any = typing.Any │ │ │ │ Dict = typing.Dict │ │ │ │ HuggingFaceEmbeddings = <class │ │ │ │ 'langchain.embeddings.huggingface.HuggingFaceEmbeddings'> │ │ │ │ HuggingFaceInstructEmbeddings = <class │ │ │ │ 'langchain.embeddings.huggingface.HuggingFaceInstructEmbedd… │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ModuleNotFoundError: No module named 'langchain.embeddings.base' (chatdocs) chris@CM-PC:/mnt/i/chatdocs/chatdocs$ cd chatdocs (chatdocs) chris@CM-PC:/mnt/i/chatdocs/chatdocs/chatdocs$ chatdocs download ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ /mnt/i/chatdocs/chatdocs/chatdocs/main.py:23 in download │ │ │ │ 20 │ │ 21 @app.command() │ │ 22 def download(config: ConfigPath = None): │ │ ❱ 23 │ from .download import download │ │ 24 │ │ │ 25 │ config = get_config(config) │ │ 26 │ download(config=config) │ │ │ │ ╭─── locals ────╮ │ │ │ config = None │ │ │ ╰───────────────╯ │ │ │ │ /mnt/i/chatdocs/chatdocs/chatdocs/download.py:3 in <module> │ │ │ │ 1 from typing import Any, Dict │ │ 2 │ │ ❱ 3 from .embeddings import get_embeddings │ │ 4 from .llms import get_llm │ │ 5 │ │ 6 │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ __builtins__ = { │ │ │ │ │ '__name__': 'builtins', │ │ │ │ │ '__doc__': 'Built-in functions, exceptions, and other │ │ │ │ objects.\n\nNoteworthy: None is the nil'+46, │ │
│ │ │ 'package': '', │ │
│ │ │ 'loader': <class '_frozen_importlib.BuiltinImporter'>, │ │
│ │ │ 'spec': ModuleSpec(name='builtins', loader=<class │ │
│ │ '_frozen_importlib.BuiltinImporter'>, origin='built-in'), │ │
│ │ │ 'build_class': , │ │
│ │ │ 'import': , │ │
│ │ │ 'abs': , │ │
│ │ │ 'all': , │ │
│ │ │ 'any': , │ │
│ │ │ ... +145 │ │
│ │ } │ │
│ │ cached = '/mnt/i/chatdocs/chatdocs/chatdocs/pycache/download.cpython-310.pyc' │ │
│ │ doc = None │ │
│ │ file = '/mnt/i/chatdocs/chatdocs/chatdocs/download.py' │ │
│ │ loader = <_frozen_importlib_external.SourceFileLoader object at 0x7f2004faed40> │ │
│ │ name = 'chatdocs.download' │ │
│ │ package = 'chatdocs' │ │
│ │ spec = ModuleSpec(name='chatdocs.download', │ │
│ │ loader=<_frozen_importlib_external.SourceFileLoader object at │ │
│ │ 0x7f2004faed40>, origin='/mnt/i/chatdocs/chatdocs/chatdocs/download.py') │ │
│ │ Any = typing.Any │ │
│ │ Dict = typing.Dict │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /mnt/i/chatdocs/chatdocs/chatdocs/embeddings.py:4 in │
│ │
│ 1 from typing import Any, Dict │
│ 2 │
│ 3 from langchain.embeddings import HuggingFaceInstructEmbeddings, HuggingFaceEmbeddings │
│ ❱ 4 from langchain.embeddings.base import Embeddings │
│ 5 │
│ 6 │
│ 7 def get_embeddings(config: Dict[str, Any]) -> Embeddings: │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ builtins = { │ │
│ │ │ 'name': 'builtins', │ │
│ │ │ 'doc': 'Built-in functions, exceptions, and other │ │
│ │ objects.\n\nNoteworthy: None is the nil'+46, │ │ │ │ │ '__package__': '', │ │ │ │ │ '__loader__': <class │ │ │ │ '_frozen_importlib.BuiltinImporter'>, │ │ │ │ │ '__spec__': ModuleSpec(name='builtins', loader=<class │ │ │ │ '_frozen_importlib.BuiltinImporter'>, origin='built-in'), │ │ │ │ │ '__build_class__': <built-in function __build_class__>, │ │ │ │ │ '__import__': <built-in function __import__>, │ │ │ │ │ 'abs': <built-in function abs>, │ │ │ │ │ 'all': <built-in function all>, │ │ │ │ │ 'any': <built-in function any>, │ │ │ │ │ ... +145 │ │ │ │ } │ │ │ │ __cached__ = '/mnt/i/chatdocs/chatdocs/chatdocs/__pycache__/embeddings.c… │ │ │ │ __doc__ = None │ │ │ │ __file__ = '/mnt/i/chatdocs/chatdocs/chatdocs/embeddings.py' │ │ │ │ __loader__ = <_frozen_importlib_external.SourceFileLoader object at │ │ │ │ 0x7f2004faeec0> │ │ │ │ __name__ = 'chatdocs.embeddings' │ │ │ │ __package__ = 'chatdocs' │ │ │ │ __spec__ = ModuleSpec(name='chatdocs.embeddings', │ │ │ │ loader=<_frozen_importlib_external.SourceFileLoader object │ │ │ │ at 0x7f2004faeec0>, │ │ │ │ origin='/mnt/i/chatdocs/chatdocs/chatdocs/embeddings.py') │ │ │ │ Any = typing.Any │ │ │ │ Dict = typing.Dict │ │ │ │ HuggingFaceEmbeddings = <class │ │ │ │ 'langchain.embeddings.huggingface.HuggingFaceEmbeddings'> │ │ │ │ HuggingFaceInstructEmbeddings = <class │ │ │ │ 'langchain.embeddings.huggingface.HuggingFaceInstructEmbedd… │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ModuleNotFoundError: No module named 'langchain.embeddings.base' (chatdocs) chris@CM-PC:/mnt/i/chatdocs/chatdocs/chatdocs$ cd .. (chatdocs) chris@CM-PC:/mnt/i/chatdocs/chatdocs$ cd .. (chatdocs) chris@CM-PC:/mnt/i/chatdocs$ chatdocs download ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ /mnt/i/chatdocs/chatdocs/chatdocs/main.py:23 in download │ │ │ │ 20 │ │ 21 @app.command() │ │ 22 def download(config: ConfigPath = None): │ │ ❱ 23 │ from .download import download │ │ 24 │ │ │ 25 │ config = get_config(config) │ │ 26 │ download(config=config) │ │ │ │ ╭─── locals ────╮ │ │ │ config = None │ │ │ ╰───────────────╯ │ │ │ │ /mnt/i/chatdocs/chatdocs/chatdocs/download.py:3 in <module> │ │ │ │ 1 from typing import Any, Dict │ │ 2 │ │ ❱ 3 from .embeddings import get_embeddings │ │ 4 from .llms import get_llm │ │ 5 │ │ 6 │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ __builtins__ = { │ │ │ │ │ '__name__': 'builtins', │ │ │ │ │ '__doc__': 'Built-in functions, exceptions, and other │ │ │ │ objects.\n\nNoteworthy: None is the nil'+46, │ │
│ │ │ 'package': '', │ │
│ │ │ 'loader': <class '_frozen_importlib.BuiltinImporter'>, │ │
│ │ │ 'spec': ModuleSpec(name='builtins', loader=<class │ │
│ │ '_frozen_importlib.BuiltinImporter'>, origin='built-in'), │ │
│ │ │ 'build_class': , │ │
│ │ │ 'import': , │ │
│ │ │ 'abs': , │ │
│ │ │ 'all': , │ │
│ │ │ 'any': , │ │
│ │ │ ... +145 │ │
│ │ } │ │
│ │ cached = '/mnt/i/chatdocs/chatdocs/chatdocs/pycache/download.cpython-310.pyc' │ │
│ │ doc = None │ │
│ │ file = '/mnt/i/chatdocs/chatdocs/chatdocs/download.py' │ │
│ │ loader = <_frozen_importlib_external.SourceFileLoader object at 0x7f94ec95ace0> │ │
│ │ name = 'chatdocs.download' │ │
│ │ package = 'chatdocs' │ │
│ │ spec = ModuleSpec(name='chatdocs.download', │ │
│ │ loader=<_frozen_importlib_external.SourceFileLoader object at │ │
│ │ 0x7f94ec95ace0>, origin='/mnt/i/chatdocs/chatdocs/chatdocs/download.py') │ │
│ │ Any = typing.Any │ │
│ │ Dict = typing.Dict │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /mnt/i/chatdocs/chatdocs/chatdocs/embeddings.py:4 in │
│ │
│ 1 from typing import Any, Dict │
│ 2 │
│ 3 from langchain.embeddings import HuggingFaceInstructEmbeddings, HuggingFaceEmbeddings │
│ ❱ 4 from langchain.embeddings.base import Embeddings │
│ 5 │
│ 6 │
│ 7 def get_embeddings(config: Dict[str, Any]) -> Embeddings: │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ builtins = { │ │
│ │ │ 'name': 'builtins', │ │
│ │ │ 'doc': 'Built-in functions, exceptions, and other │ │
│ │ objects.\n\nNoteworthy: None is the nil'+46, │ │ │ │ │ '__package__': '', │ │ │ │ │ '__loader__': <class │ │ │ │ '_frozen_importlib.BuiltinImporter'>, │ │ │ │ │ '__spec__': ModuleSpec(name='builtins', loader=<class │ │ │ │ '_frozen_importlib.BuiltinImporter'>, origin='built-in'), │ │ │ │ │ '__build_class__': <built-in function __build_class__>, │ │ │ │ │ '__import__': <built-in function __import__>, │ │ │ │ │ 'abs': <built-in function abs>, │ │ │ │ │ 'all': <built-in function all>, │ │ │ │ │ 'any': <built-in function any>, │ │ │ │ │ ... +145 │ │ │ │ } │ │ │ │ __cached__ = '/mnt/i/chatdocs/chatdocs/chatdocs/__pycache__/embeddings.c… │ │ │ │ __doc__ = None │ │ │ │ __file__ = '/mnt/i/chatdocs/chatdocs/chatdocs/embeddings.py' │ │ │ │ __loader__ = <_frozen_importlib_external.SourceFileLoader object at │ │ │ │ 0x7f94ec95ae60> │ │ │ │ __name__ = 'chatdocs.embeddings' │ │ │ │ __package__ = 'chatdocs' │ │ │ │ __spec__ = ModuleSpec(name='chatdocs.embeddings', │ │ │ │ loader=<_frozen_importlib_external.SourceFileLoader object │ │ │ │ at 0x7f94ec95ae60>, │ │ │ │ origin='/mnt/i/chatdocs/chatdocs/chatdocs/embeddings.py') │ │ │ │ Any = typing.Any │ │ │ │ Dict = typing.Dict │ │ │ │ HuggingFaceEmbeddings = <class │ │ │ │ 'langchain.embeddings.huggingface.HuggingFaceEmbeddings'> │ │ │ │ HuggingFaceInstructEmbeddings = <class │ │ │ │ 'langchain.embeddings.huggingface.HuggingFaceInstructEmbedd… │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ModuleNotFoundError: No module named 'langchain.embeddings.base'

@pierredelacelle
Copy link

Hi,

I had the same error while testing things out with chatdocs. This is coming from the change of import path of Embeddings in langchain in the latest version - 0.0.293.

Fix/pin langchain version to 0.0.292 in your environment, and you'll be good to go.
This PR ( Fixed langchain version #81 ) is covering this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants