fastembed icon indicating copy to clipboard operation
fastembed copied to clipboard

[Bug]: No module named 'fastembed'

Open giacomobartoli opened this issue 11 months ago • 6 comments

What happened?

It seems pretty oblivious, but it's not actually.

Using python 3.9 with virtual environment. Requirements txt contains fastembed. Code is pretty simple:

from fastembed import FastEmbed

def embed_search(text: str):
    model = FastEmbed(model="jinaai/jina-embeddings-v2-base-de")
    embeddings = model.embed(text)
    return embeddings

pip install -r requirements.txt --> OK

when I run the file I got:

ModuleNotFoundError: No module named 'fastembed'

I am using a virtual environment:

python3.9 -m venv venv
source venv/bin/activate

I already tried to re-run pip install fastembed

Package is installed correctly:

pip show fastembed
Name: fastembed
Version: 0.5.0
Summary: Fast, light, accurate library built for retrieval embedding generation
Home-page: https://github.com/qdrant/fastembed
Author: Qdrant Team
Author-email: [email protected]
License: Apache License
Location: /Users/giacomobartoli/Desktop/PROGETTI/ctb/ctb/venv/lib/python3.9/site-packages
Requires: huggingface-hub, loguru, mmh3, numpy, onnx, onnxruntime, pillow, py-rust-stemmers, requests, tokenizers, tqdm
Required-by: 

What is the expected behaviour?

To run successfully fastembed using a virtual environment

A minimal reproducible example

No response

What Python version are you on? e.g. python --version

Python 3.9

FastEmbed version

latest

What os are you seeing the problem on?

No response

Relevant stack traces and/or logs

No response

giacomobartoli avatar Dec 31 '24 13:12 giacomobartoli

Hi @giacomobartoli

there is no FastEmbed class in fastembed, could you point us to the resource where you found it?

The correct import is from fastembed import TextEmbedding

joein avatar Jan 02 '25 11:01 joein

@joein you're right, sorry.. my bad. I think the code was generated and I didn't double checked.

giacomobartoli avatar Jan 02 '25 11:01 giacomobartoli

I changed the code according to your comment, using TextEmbedding. The issue remains:

Import "fastembed" could not be resolvedPylancereportMissingImports

giacomobartoli avatar Jan 02 '25 13:01 giacomobartoli

If you're code is in a file called fastembed.py, then you will have issues. Rename it and it should work fine.

karbasia avatar Jan 03 '25 16:01 karbasia

the file is called qdrant.py

giacomobartoli avatar Jan 03 '25 16:01 giacomobartoli

What other packages are installed? The only way I could reproduce this was if either my test file was named fastembed.py or if there is a file named fastembed.py in the same folder as qdrant.py.

karbasia avatar Jan 08 '25 00:01 karbasia