milvus-io / milvus

A cloud-native vector database, storage for next generation AI applications
https://milvus.io
Apache License 2.0
30.29k stars 2.91k forks source link

[Bug]: Can't use MilvusClient() because it says "ModuleNotFoundError: No module named 'milvus_lite'" #34854

Closed KnightChaser closed 3 months ago

KnightChaser commented 3 months ago

Is there an existing issue for this?

Environment

- Milvus version: 2.4.4
- Deployment mode(standalone or cluster): standalone
- MQ type(rocksmq, pulsar or kafka): -
- SDK version(e.g. pymilvus v2.0.0rc2): -
- OS(Ubuntu or CentOS): Windows 11 Pro, 10.0.22631 Build 22631
- CPU/Memory: Intel i9-12900H
- GPU: NVIDIA RTX 3080 laptop
- Others: Python 3.12.3

Current Behavior

I was following the official guide's instructions to start with Milvus. (https://milvus.io/docs/quickstart.md#Insert-Data). However, when I try to use MilvusClient() function even after installing pymilvus package, I still face the runtime error that there is no package named "milvus_lite". I'm not entirely sure if it's a bug or something else, technically. However, I searched over the Internet, and I couldn't find a way to resolve this myself for now.

Of course, I installed pymilvus package as the guide instructed.

pip install -U pymilvus

Full context of my situation is the following:

PS C:\Users\3NR1QUE> python --version       
Python 3.12.3
PS C:\Users\3NR1QUE> pip freeze | findstr milvus
pymilvus==2.4.4
PS C:\Users\3NR1QUE> python
Python 3.12.3 (tags/v3.12.3:f6650f9, Apr  9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pymilvus import MilvusClient
>>> client = MilvusClient("test.db")     
Failed to create new connection using: f9aec64b95054209af2dbc5c67807ded
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\github-local\KnightChaser\MITREAttackRagger\venv\Lib\site-packages\pymilvus\milvus_client\milvus_client.py", line 58, in __init__
    self._using = self._create_connection(
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\github-local\KnightChaser\MITREAttackRagger\venv\Lib\site-packages\pymilvus\milvus_client\milvus_client.py", line 651, in _create_connection
    raise ex from ex
  File "D:\github-local\KnightChaser\MITREAttackRagger\venv\Lib\site-packages\pymilvus\milvus_client\milvus_client.py", line 648, in _create_connection
    connections.connect(using, user, password, db_name, token, uri=uri, **kwargs)
  File "D:\github-local\KnightChaser\MITREAttackRagger\venv\Lib\site-packages\pymilvus\orm\connections.py", line 378, in connect
    from milvus_lite.server_manager import server_manager_instance
ModuleNotFoundError: No module named 'milvus_lite'

Expected Behavior

I expected I could use the MilvusClient function without any runtime error to continue following the guide.

Steps To Reproduce

In Windows environment, install Milvus via pip install -U pymilvus. Then, open the python shell and try to use MilvusClient().

from pymilvus import MilvusClient

client = MilvusClient("milvus_demo.db")

Milvus Log

No response

Anything else?

I'm not sure if It'll be helpful to address my issue clearer, but I got the following runtime error logs after I reproduced the same issue on Jupyter notebook.

{
    "name": "ModuleNotFoundError",
    "message": "No module named 'milvus_lite'",
    "stack": "---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
    [... skipping hidden 1 frame]

Cell In[11], line 3
      1 from pymilvus import MilvusClient
----> 3 client = MilvusClient(\"milvus_demo.db\")

File d:\\github-local\\KnightChaser\\MITREAttackRagger\\venv\\Lib\\site-packages\\pymilvus\\milvus_client\\milvus_client.py:58, in MilvusClient.__init__(self, uri, user, password, db_name, token, timeout, **kwargs)
     46 \"\"\"A client for the common Milvus use case.
     47 
     48 This client attempts to hide away the complexity of using Pymilvus. In a lot ofcases what
   (...)
     56         to None.
     57 \"\"\"
---> 58 self._using = self._create_connection(
     59     uri, user, password, db_name, token, timeout=timeout, **kwargs
     60 )
     61 self.is_self_hosted = bool(utility.get_server_type(using=self._using) == \"milvus\")

File d:\\github-local\\KnightChaser\\MITREAttackRagger\\venv\\Lib\\site-packages\\pymilvus\\milvus_client\\milvus_client.py:651, in MilvusClient._create_connection(self, uri, user, password, db_name, token, **kwargs)
    650     logger.error(\"Failed to create new connection using: %s\", using)
--> 651     raise ex from ex
    652 else:

File d:\\github-local\\KnightChaser\\MITREAttackRagger\\venv\\Lib\\site-packages\\pymilvus\\milvus_client\\milvus_client.py:648, in MilvusClient._create_connection(self, uri, user, password, db_name, token, **kwargs)
    647 try:
--> 648     connections.connect(using, user, password, db_name, token, uri=uri, **kwargs)
    649 except Exception as ex:

File d:\\github-local\\KnightChaser\\MITREAttackRagger\\venv\\Lib\\site-packages\\pymilvus\\orm\\connections.py:378, in Connections.connect(self, alias, user, password, db_name, token, **kwargs)
    374     raise ConnectionConfigException(
    375         message=f\"Open local milvus failed, dir: {parent_path} is not exists\"
    376     )
--> 378 from milvus_lite.server_manager import server_manager_instance
    380 local_uri = server_manager_instance.start_and_get_uri(kwargs[\"uri\"])

ModuleNotFoundError: No module named 'milvus_lite'

The above exception was the direct cause of the following exception:

ModuleNotFoundError                       Traceback (most recent call last)
    [... skipping hidden 1 frame]

Cell In[11], line 3
      1 from pymilvus import MilvusClient
----> 3 client = MilvusClient(\"milvus_demo.db\")

File d:\\github-local\\KnightChaser\\MITREAttackRagger\\venv\\Lib\\site-packages\\pymilvus\\milvus_client\\milvus_client.py:58, in MilvusClient.__init__(self, uri, user, password, db_name, token, timeout, **kwargs)
     46 \"\"\"A client for the common Milvus use case.
     47 
     48 This client attempts to hide away the complexity of using Pymilvus. In a lot ofcases what
   (...)
     56         to None.
     57 \"\"\"
---> 58 self._using = self._create_connection(
     59     uri, user, password, db_name, token, timeout=timeout, **kwargs
     60 )
     61 self.is_self_hosted = bool(utility.get_server_type(using=self._using) == \"milvus\")

File d:\\github-local\\KnightChaser\\MITREAttackRagger\\venv\\Lib\\site-packages\\pymilvus\\milvus_client\\milvus_client.py:651, in MilvusClient._create_connection(self, uri, user, password, db_name, token, **kwargs)
    650     logger.error(\"Failed to create new connection using: %s\", using)
--> 651     raise ex from ex
    652 else:

File d:\\github-local\\KnightChaser\\MITREAttackRagger\\venv\\Lib\\site-packages\\pymilvus\\milvus_client\\milvus_client.py:648, in MilvusClient._create_connection(self, uri, user, password, db_name, token, **kwargs)
    647 try:
--> 648     connections.connect(using, user, password, db_name, token, uri=uri, **kwargs)
    649 except Exception as ex:

File d:\\github-local\\KnightChaser\\MITREAttackRagger\\venv\\Lib\\site-packages\\pymilvus\\orm\\connections.py:378, in Connections.connect(self, alias, user, password, db_name, token, **kwargs)
    374     raise ConnectionConfigException(
    375         message=f\"Open local milvus failed, dir: {parent_path} is not exists\"
    376     )
--> 378 from milvus_lite.server_manager import server_manager_instance
    380 local_uri = server_manager_instance.start_and_get_uri(kwargs[\"uri\"])

ModuleNotFoundError: No module named 'milvus_lite'

The above exception was the direct cause of the following exception:

ModuleNotFoundError                       Traceback (most recent call last)
Cell In[11], line 3
      1 from pymilvus import MilvusClient
----> 3 client = MilvusClient(\"milvus_demo.db\")

File d:\\github-local\\KnightChaser\\MITREAttackRagger\\venv\\Lib\\site-packages\\pymilvus\\milvus_client\\milvus_client.py:58, in MilvusClient.__init__(self, uri, user, password, db_name, token, timeout, **kwargs)
     36 def __init__(
     37     self,
     38     uri: str = \"http://localhost:19530\",
   (...)
     44     **kwargs,
     45 ) -> None:
     46     \"\"\"A client for the common Milvus use case.
     47 
     48     This client attempts to hide away the complexity of using Pymilvus. In a lot ofcases what
   (...)
     56             to None.
     57     \"\"\"
---> 58     self._using = self._create_connection(
     59         uri, user, password, db_name, token, timeout=timeout, **kwargs
     60     )
     61     self.is_self_hosted = bool(utility.get_server_type(using=self._using) == \"milvus\")

File d:\\github-local\\KnightChaser\\MITREAttackRagger\\venv\\Lib\\site-packages\\pymilvus\\milvus_client\\milvus_client.py:651, in MilvusClient._create_connection(self, uri, user, password, db_name, token, **kwargs)
    649 except Exception as ex:
    650     logger.error(\"Failed to create new connection using: %s\", using)
--> 651     raise ex from ex
    652 else:
    653     logger.debug(\"Created new connection using: %s\", using)

File d:\\github-local\\KnightChaser\\MITREAttackRagger\\venv\\Lib\\site-packages\\pymilvus\\milvus_client\\milvus_client.py:648, in MilvusClient._create_connection(self, uri, user, password, db_name, token, **kwargs)
    646 using = uuid4().hex
    647 try:
--> 648     connections.connect(using, user, password, db_name, token, uri=uri, **kwargs)
    649 except Exception as ex:
    650     logger.error(\"Failed to create new connection using: %s\", using)

File d:\\github-local\\KnightChaser\\MITREAttackRagger\\venv\\Lib\\site-packages\\pymilvus\\orm\\connections.py:378, in Connections.connect(self, alias, user, password, db_name, token, **kwargs)
    373 if not parent_path.is_dir():
    374     raise ConnectionConfigException(
    375         message=f\"Open local milvus failed, dir: {parent_path} is not exists\"
    376     )
--> 378 from milvus_lite.server_manager import server_manager_instance
    380 local_uri = server_manager_instance.start_and_get_uri(kwargs[\"uri\"])
    381 if local_uri is None:

ModuleNotFoundError: No module named 'milvus_lite'"
}
KnightChaser commented 3 months ago

Ah, should I use this on Linux and it's fundamentally incompatible with Windows?

yanliang567 commented 3 months ago

Milvus_lite does not support running on Windows yet, we are working on it. Please retry on Linux @KnightChaser https://milvus.io/docs/milvus_lite.md#Set-up-Milvus-Lite

yanliang567 commented 3 months ago

/assign @KnightChaser /unassign

KnightChaser commented 3 months ago

Found that it works on Ubuntu WSL 22.04. Thanks for the clarification and hope there will be Windows support soon!

(As expected, the Milvus standalone server via Docker deployment on the Windows platform didn't work properly. Thus, I just migrated my previous work to Ubuntu WSL.)

yanliang567 commented 3 months ago

okay, I'd close this issue if you don't mind. please free to open new issues if you met any new problems