Find answers from the community

Updated 4 months ago

Has anyone figured out how to get

Has anyone figured out how to get intelisesnse to index the llama_index package? It seems to be able to import stuff from llama_cloud like TextNode, but it has absolutely no idea what is exported from the llama_index package. Thanks so much for the help, I've spent a rediculous 3 hours on this issue today πŸ€¦β€β™‚οΈ
Attachments
Screenshot_2024-08-22_at_12.25.27_PM.png
Screenshot_2024-08-22_at_12.25.55_PM.png
2
b
a
L
24 comments
I've struggled with this too, I've always assumed it was my pyenv setup but commenting here to keep track for solution πŸ™‚
I assumed that as well until I spent all day digging into the issue 😫
For some reason I've never had an issue with this πŸ˜…

I just point vscode to my venv and it just works?
Attachment
image.png
@Logan M but is that inside of the llama-index repo, and, not a repo that is installing llama-index via like pip (no poetry)?
@alfredmadere do you use poetry?
@bmax I am using venv, not poetry
true... let me try with a project instead of using the repo
Yep works for me the same way
To reproduce the behavior I'm seeing, you'll need to set
"python.analysis.autoImportCompletions": true,

In your settings.json.

Then, place your cursor over SimpleChatEngine and press ctrl+space. Intelisense should suggest SimpleChatEngine as an import the same way it does when you ctrl+space on TextNode.

I have my workspace setup using the most standard .venv virtual environment with only llama-index installed via
pip install llama-index
hmm, I'm not able to get auto import completions working (it doesn't seem to pick up anything in llama-index)

But otherwise everything seems to work (imports are recognized, etc.)
Likely due to it being a namespaced package? Not sure how vscode decides where/how to search for auto imports
claude gave some decent suggestions for how to fix this

Plain Text
Configure extraPaths in settings.json:
You can help VSCode find your packages by adding their paths to the python.analysis.extraPaths setting:

VSCode settings.json configuration

{
     "python.analysis.extraPaths": [
       "${workspaceFolder}/.venv/lib/python3.x/site-packages/llama_index/core",
       "${workspaceFolder}/.venv/lib/python3.x/site-packages/llama_index/llms/openai",
       ...
     ]
   }
But a bit annoying to have to put each one probably
Ah, glad i'm not going crazy. Thanks for checking into it. I did notice that things work just fine when importing from llama_cloud, which seems to just list every single export in the top level init.py. Weird that intelisense would refuse to recursively check for exported types under the llama_index package
I agree, really weird behaviour. The namespaced package structure must be tripping it up
Also I verified that extraPaths is a decent workaround
but you have to add each one?
You just have to go as deep as the first init.py file
so you can get all of core with one line
can you send what you have
also, i've accepted this is just a me problem:
Attachment
image.png
Sure thing
Plain Text
{
  "python.testing.pytestArgs": [
    "tests"
  ],
   "python.analysis.autoImportCompletions": true,
  "python.defaultInterpreterPath": "./.venv",
  "python.testing.pytestEnabled": true,
  "python.analysis.typeCheckingMode": "basic",
  "python.analysis.extraPaths": [
    "${workspaceFolder}/new-venv/lib/python3.11/site-packages/llama_index/core"
],
"python.languageServer": "Pylance",
}
@bmax this is a weird pydantic thing. Its aliased as extra_info under the hood, both params set the same attribute
I use poetry and just point my Python interpreter to the results of virtual env executable poetry env info:

Plain Text
ο…Ή  ~/s/camp_researcher   main wip !1 ?4 ❯ poetry env info                          camp-researcher-py3.12

Virtualenv
Python:         3.12.5
Implementation: CPython
Path:           /Users/jason/Library/Caches/pypoetry/virtualenvs/myproject-YsZBHIU0-py3.12
Executable:     /Users/jason/Library/Caches/pypoetry/virtualenvs/myproject-YsZBHIU0-py3.12/bin/python
Valid:          True


Once I do that all the symbols resolve without any more issues. If a symbol is missing, poetry add needed-package and it instantly resolves.
Add a reply
Sign up and join the conversation on Discord