Lesson 1 - Semantic Search:TypeError: 'NoneType' object is not iterable

Anyone runs into the same error as me do?if INDEX_NAME in [index.name for index in pinecone.list_indexes()] get an error 'NoneType' object is not iterable
`

pinecone = Pinecone(api_key=PINECONE_API_KEY)
INDEX_NAME = utils.create_dlai_index_name('dl-ai')

if INDEX_NAME in [index.name for index in pinecone.list_indexes()]:
    pinecone.delete_index(INDEX_NAME)
print(INDEX_NAME)
pinecone.create_index(name=INDEX_NAME, 
    dimension=model.get_sentence_embedding_dimension(), 
    metric='cosine',
    spec=ServerlessSpec(cloud='aws', region='us-west-2'))

index = pinecone.Index(INDEX_NAME)
print(index)

Hi @Shengxin_Huang
You can use print() to see the variable value. Probably you are trying to use a not initialized variable.
Keep learning!

There is an error in the example code in google colab


TypeError Traceback (most recent call last)
Cell In[58], line 4
1 pinecone = Pinecone(api_key=PINECONE_API_KEY)
2 INDEX_NAME = utils.create_dlai_index_name(‘dl-ai’)
----> 4 if INDEX_NAME in [index.name for index in pinecone.list_indexes()]:
5 pinecone.delete_index(INDEX_NAME)
6 print(INDEX_NAME)

File /usr/local/lib/python3.10/site-packages/pinecone/models/index_list.py:18, in IndexList.iter(self)
17 def iter(self):
—> 18 return iter(self.index_list.indexes)

TypeError: ‘NoneType’ object is not iterable

Did you find any solution?

gosh … nobody is answering that issue.
quite hardcore start, actually

error not corrected

I have run into the same error.
While trying to trace down the source, I tried checking why, I reached the following coinclusion:
print(PINECONE KEY) → this prints some value.
I have a personal pinecone key, this does NOT look like that.

The next step - see why the None came:
print(pinecone.list_indexes())
This has the following response:
{‘error’: 'Access control denied: Principal missing permission: ’
‘control::index::list’}

Does this basically mean an expired or a revoked key?

Hi guys I got the same issue still can not fix it.
TypeError Traceback (most recent call last)
Cell In[10], line 4
1 pinecone = Pinecone(api_key=PINECONE_API_KEY)
2 INDEX_NAME = utils.create_dlai_index_name(‘dl-ai’)
----> 4 if INDEX_NAME in [index.name for index in pinecone.list_indexes()]:
5 pinecone.delete_index(INDEX_NAME)
6 print(INDEX_NAME)

File ~/.local/lib/python3.10/site-packages/pinecone/models/index_list.py:18, in IndexList._iter_(self)
17 def _iter_(self):
—> 18 return iter(self.index_list.indexes)

TypeError: ‘NoneType’ object is not iterable
I have been trying chatGPT to help it, fix it many times but still can not do it. Anyone can help?