Search code examples
pythonvector-databasemilvusrag

Why do i get "ImportError: sys.meta_path is None, Python is likely shutting down" when trying to run Milvus


I have very simple code:

from pymilvus import MilvusClient

client = MilvusClient("milvus.db")
print("hello")

which prints out this:

hello
Exception ignored in: <function ServerManager.__del__ at 0x7f1b80758ea0>
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/dist-packages/milvus_lite/server_manager.py", line 58, in __del__
  File "/usr/local/lib/python3.12/dist-packages/milvus_lite/server_manager.py", line 53, in release_all
  File "/usr/local/lib/python3.12/dist-packages/milvus_lite/server.py", line 118, in stop
  File "/usr/lib/python3.12/pathlib.py", line 1164, in __init__
  File "/usr/lib/python3.12/pathlib.py", line 358, in __init__
ImportError: sys.meta_path is None, Python is likely shutting down
Exception ignored in: <function Server.__del__ at 0x7f1b80758cc0>
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/dist-packages/milvus_lite/server.py", line 122, in __del__
  File "/usr/local/lib/python3.12/dist-packages/milvus_lite/server.py", line 118, in stop
  File "/usr/lib/python3.12/pathlib.py", line 1164, in __init__
  File "/usr/lib/python3.12/pathlib.py", line 358, in __init__
ImportError: sys.meta_path is None, Python is likely shutting down

As you can see i get the error for some reason. Why ?


Solution

  • See:

    https://github.com/milvus-io/pymilvus/issues/1746

    This is most likely due to you running Python 3.12 which is not supported by a lot of the libraries in AI. I recommend setting up a virtual environment with Python 3.9 or Python 3.10.

    You can make sure all of your Python 3 tools are current.

    https://pypi.org/project/pymilvus/

    Your code is not the problem it is your Python environment. What operating system are you running?