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

AttributeError: type object 'hnswlib.Index' has no attribute 'file_handle_count' #1012

Closed
Comput3rUs3r opened this issue Sep 5, 2023 · 19 comments
Labels
primordial Related to the primordial version of PrivateGPT, which is now frozen in favour of the new PrivateGPT

Comments

@Comput3rUs3r
Copy link

Getting this error when running python ingest.py
(privategpt) D:\privategpt\privateGPT>python ingest.py
Traceback (most recent call last):
File "D:\privategpt\privateGPT\ingest.py", line 169, in
main()
File "D:\privategpt\privateGPT\ingest.py", line 146, in main
chroma_client = chromadb.PersistentClient(settings=CHROMA_SETTINGS , path=persist_directory)
File "C:\Users\Itanimulli\AppData\Local\Programs\Python\Python310\lib\site-packages\chromadb_init_.py", line 106, in PersistentClient
return Client(settings)
File "C:\Users\Itanimulli\AppData\Local\Programs\Python\Python310\lib\site-packages\chromadb_init_.py", line 143, in Client
api = system.instance(API)
File "C:\Users\Itanimulli\AppData\Local\Programs\Python\Python310\lib\site-packages\chromadb\config.py", line 243, in instance
impl = type(self)
File "C:\Users\Itanimulli\AppData\Local\Programs\Python\Python310\lib\site-packages\chromadb\api\segment.py", line 82, in init
self._manager = self.require(SegmentManager)
File "C:\Users\Itanimulli\AppData\Local\Programs\Python\Python310\lib\site-packages\chromadb\config.py", line 184, in require
inst = self._system.instance(type)
File "C:\Users\Itanimulli\AppData\Local\Programs\Python\Python310\lib\site-packages\chromadb\config.py", line 243, in instance
impl = type(self)
File "C:\Users\Itanimulli\AppData\Local\Programs\Python\Python310\lib\site-packages\chromadb\segment\impl\manager\local.py", line 73, in init
// PersistentLocalHnswSegment.get_file_handle_count()
File "C:\Users\Itanimulli\AppData\Local\Programs\Python\Python310\lib\site-packages\chromadb\segment\impl\vector\local_persistent_hnsw.py", line 405, in get_file_handle_count
hnswlib_count = hnswlib.Index.file_handle_count
AttributeError: type object 'hnswlib.Index' has no attribute 'file_handle_count'

@JoeLorenzoMontano
Copy link

I am also running into this error.

@bigcat26
Copy link

bigcat26 commented Sep 8, 2023

+1. same issue

It seems a bug of chroma-hnswlib which depends by chromadb, downgrade to chromadb 0.4.3 solves the issue.

@Ananderz
Copy link

Same error, however downgrading to 0.4.3 did not fix the issue for me. Trying to figure it out

@SuperSlamUSA
Copy link

Same problem here. Is planned to solve this? How did you work around this error? Downgrading to 0.4.3 did not fix the issue for me neither.

@DLOVRIC2
Copy link

DLOVRIC2 commented Oct 1, 2023

I am on Python 3.10.13 and downgrading to 0.4.3 fixed the issue for me.

After downgrading this is what I have:

Name: chromadb
Version: 0.4.3

Name: hnswlib
Version: 0.7.0

Name: chroma-hnswlib
Version: 0.7.1

pseudotensor added a commit to h2oai/h2ogpt that referenced this issue Oct 7, 2023
@LIdro
Copy link

LIdro commented Oct 13, 2023

The problem is caused by poorly commenting the line

// PersistentLocalHnswSegment.get_file_handle_count()

To solve this, you need to:

  • look for the line in the error stack that shows
    File "C:\Users\phyln\AppData\Local\Programs\Python\Python311\Lib\site-packages\chromadb\segment\impl\manager\local.py", line 73, in init
    // PersistentLocalHnswSegment.get_file_handle_count()
  • then you shift click on the link (or copy and paste the link in your file explorer).
  • If you followed the link, you will need to open the local.py file in you IDE and edit the line 73 as below.

# PersistentLocalHnswSegment.get_file_handle_count()

That should solve your problem.

@MosterCheeseInc
Copy link

The problem is caused by poorly commenting the line

// PersistentLocalHnswSegment.get_file_handle_count()

To solve this, you need to:

  • look for the line in the error stack that shows
    File "C:\Users\phyln\AppData\Local\Programs\Python\Python311\Lib\site-packages\chromadb\segment\impl\manager\local.py", line 73, in init
    // PersistentLocalHnswSegment.get_file_handle_count()
  • then you shift click on the link (or copy and paste the link in your file explorer).
  • If you followed the link, you will need to open the local.py file in you IDE and edit the line 73 as below.

PersistentLocalHnswSegment.get_file_handle_count()

That should solve your problem.

This worked for me fixed the issue I had with completing the >python ingest.py

@imartinez imartinez added the primordial Related to the primordial version of PrivateGPT, which is now frozen in favour of the new PrivateGPT label Oct 19, 2023
@macksjlazarus
Copy link

The problem is caused by poorly commenting the line

// PersistentLocalHnswSegment.get_file_handle_count()

To solve this, you need to:

* look for the line in the error stack that shows
  File "C:\Users\phyln\AppData\Local\Programs\Python\Python311\Lib\site-packages\chromadb\segment\impl\manager\local.py", line 73, in **init**
  // PersistentLocalHnswSegment.get_file_handle_count()

* then you shift click on the link (or copy and paste the link in your file explorer).

* If you followed the link, you will need to open the local.py file in you IDE and edit the line 73 as below.

PersistentLocalHnswSegment.get_file_handle_count()

That should solve your problem.

This worked for me!

@HammadB
Copy link

HammadB commented Dec 18, 2023

Hi folks - I don't think this is due to "poorly commenting" the line. // PersistentLocalHnswSegment.get_file_handle_count() is floor division by the file handle count of the index.

The problem here is likely that you have both hnswlib and chroma-hnswlib in your env, we need to clean this up but hnswlib shadows chroma-hnswlib. Can you remove hnswlib from your env (using pip freeze to confirm) and this should go away.

Sorry for the confusion.

@BullzeyeBG
Copy link

BullzeyeBG commented Dec 19, 2023

Hi folks - I don't think this is due to "poorly commenting" the line. // PersistentLocalHnswSegment.get_file_handle_count() is floor division by the file handle count of the index.

The problem here is likely that you have both hnswlib and chroma-hnswlib in your env, we need to clean this up but hnswlib shadows chroma-hnswlib. Can you remove hnswlib from your env (using pip freeze to confirm) and this should go away.

Sorry for the confusion.

This worked for me - uninstalled "hnswlid" but kept "chroma-hnswlib".
Also - guys, do not follow the suggestion above to comment line 73, cause it will deem your chromadb unusable - I spent 3 hours wondering why my similarity search would not work!!!

Just follow the hnswlib advise!

@Prathmesh-1991
Copy link

Hi folks - I don't think this is due to "poorly commenting" the line. // PersistentLocalHnswSegment.get_file_handle_count() is floor division by the file handle count of the index.
The problem here is likely that you have both hnswlib and chroma-hnswlib in your env, we need to clean this up but hnswlib shadows chroma-hnswlib. Can you remove hnswlib from your env (using pip freeze to confirm) and this should go away.
Sorry for the confusion.

This worked for me - uninstalled "hnswlid" but kept "chroma-hnswlib". Also - guys, do not follow the suggestion above to comment line 73, cause it will deem your chromadb unusable - I spent 3 hours wondering why my similarity search would not work!!!

Just follow the hnswlib advise!

I have tried uninstalling hnswlib and importing import chroma-hnswlib but it is giving me error
from chromadb.segment.impl.vector.local_hnsw import (
File "C:\Private GPT\privategpt\lib\site-packages\chromadb\segment\impl\vector\local_hnsw.py", line 27
import chroma-hnswlib

@quantuan125
Copy link

Why is this closed? This issue is never solved properly.

@MichaelJWelsh
Copy link

Still having issues ^^^

@anilpillai007
Copy link

anilpillai007 commented Apr 9, 2024

Still having issues. Tried the above

  1. pip3 install chromadb==0.4.3 resulted in
    - Successfully installed chroma-hnswlib-0.7.1 chromadb-0.4.3 fastapi-0.99.1 pydantic-1.10.15 starlette-0.27.0
  2. removed hnswlib
  3. And it still gave the error
    AttributeError: type object 'hnswlib.Index' has no attribute 'file_handle_count'

@anilpillai007
Copy link

okay I figured it. It is primarily a path problem.

  1. I had multiple "local_persistent_hnsw.py" files, and it was picking from the wrong directory. That wrong file had a call to get_file_handle_count()
  2. I uninstalled that version of chromadb and it solved the problem. I never used that version anyways.

E.g. on my mac, I had

  1. /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chromadb/segment/impl/vector/local_persistent_hnsw.py
  2. /usr/local/lib/python3.11/site-packages/chromadb/segment/impl/vector/local_persistent_hnsw.py

I ran "pip uninstall chromadb" and it removed the 2nd local_persistent_hnsw.py

One should never go ahead and edit the installed files like someone had commented earlier.

@inteligenciamilgrau
Copy link

For me I uninstall both chroma-hnswlib and hnswlib. And installed again chroma-hnswlib.

pip uninstall hnswlib
pip uninstall chroma-hnswlib
pip install chroma-hnswlib

@Lockearaec
Copy link

Thx to yall for the trouble shoots!

@Danielskry
Copy link

okay I figured it. It is primarily a path problem.

1. I had multiple "local_persistent_hnsw.py" files, and it was picking from the wrong directory.  That wrong file had a call to  get_file_handle_count()

2. I uninstalled that version of chromadb and it solved the problem. I never used that version anyways.

E.g. on my mac, I had

1. /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chromadb/segment/impl/vector/local_persistent_hnsw.py

2. /usr/local/lib/python3.11/site-packages/chromadb/segment/impl/vector/local_persistent_hnsw.py

I ran "pip uninstall chromadb" and it removed the 2nd local_persistent_hnsw.py

One should never go ahead and edit the installed files like someone had commented earlier.

Cheers for this! This was also my problem. In my case I was using Poetry and after having installed both hnswlib and chroma-hnswlib I got this issue. Removing them from the pyproject.toml didn't help, I had to manually delete the current environment and reinstall it.

@mehedihassanbinhafiz
Copy link

I am on Python 3.10.13 and downgrading to 0.4.3 fixed the issue for me.

After downgrading this is what I have:

Name: chromadb Version: 0.4.3

Name: hnswlib Version: 0.7.0

Name: chroma-hnswlib Version: 0.7.1

This solution is working for me. Though I am using python 3.8.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
primordial Related to the primordial version of PrivateGPT, which is now frozen in favour of the new PrivateGPT
Projects
None yet
Development

No branches or pull requests