How to search through all installed python packages for a class in vscode?
Asked Answered
M

3

9

In vscode, is it possible to search for given symbol (class, function, etc) through current project files and all installed python packages? For example in pycharm I can press Shift 3 times and search dialog appears, I write class name like "PTransform", mark checkbox "include non-project items" and I get all the modules/files where given symbol is defined. Is it possible to do in vscode?

I know there is "search" pane in side bar, but it only searches for strings and only through current project files, not all installed python packages.

Mroz answered 16/12, 2020 at 13:48 Comment(2)
Have you tried CTRL+SHIFT+F in vscode workspace?Bwana
yes, it's the "search" in side bar - it only searches current project filesMroz
B
3

A workaround: You can add <site-packages> to folder and save the workspace. Now ctrl-shift-F can search project directory and also <site-packages>

Brevier answered 19/12, 2022 at 10:27 Comment(1)
Can you elaborate what it means exactly to "add <site-packages> to folder"?Standpipe
H
0

In VSCode, its search function is to search all files in the current project by default.

Therefore, since you want to search for the content including the installed Python module, it is recommended that you use a virtual environment. The Python module will be stored in this environment and exist in the current project.

For example, search for the method "configuration" in the "setup.py" file in the Python module package "numpy":

enter image description here

For searching all installed'Python modules' that are not stored in the current open, I submitted this question on Github, and let us look forward to the realization of this function.

Link: Is it possible to search for all installed Python modules, including those that are not stored in the project?

Histolysis answered 17/12, 2020 at 2:9 Comment(5)
I do use virtual environment, but it is not in the same folder as my project. I use poetry for venv management and vscode doesn't search through installed packages in this venv (like pycharm does).Mroz
Thank you, but the realization seems to be unlikely... At least I know it's not possible in vscode currently.Mroz
Yes, using a virtual environment is a workaround currently.Histolysis
I do use a virtual environment. Workaround is - supposedly - to move the virtual environment to the same folder as python code that I write. And even then only string search would work (AFAIK there is no symbol search functionality in vscode).Mroz
I wish that it behaved like PyCharm in this regard :(Benedix
S
0

For me, pressing CTRL+SHIFT+F and adding /path/to/myEnv/site-packages to the "files to include" textbox allows me to search in the modules of that virtual environment.
Note: I am using conda, and have not tested whether this also works with other virtual environment managers.

What I put in my search bar

Standpipe answered 14/9, 2024 at 13:0 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.