microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.33k stars 1.19k forks source link

Remove autocomplete.preloadModules #1704

Closed asierralozano closed 6 years ago

asierralozano commented 6 years ago

Environment data

Actual behavior

Referencing this question: https://stackoverflow.com/questions/49912163/vscode-add-preloaded-module-from-extrapath/49926294#49926294

I have added the maya's completion path to python.autocomplete.extraPaths(/Applications/Autodesk/maya2018/devkit/other/pymel/extras/completion/py) available to download by the Autodesk Maya's DevKit, because I would like to have the intellisense working with those modules.

Then, i have also added the module "maya" to python.autocomplete.preloadModules, because I would like to speed up the intellisense, but I think that is not working at all. It takes like 10 seconds to show the intellisense options

Steps to reproduce:

1- You can download the Maya's DevKit with it's own autocomplete modules from here: https://apps.autodesk.com/MAYA/en/Detail/Index?id=5525491636376351277&os=Win64&appLang=en

2- Unzip the file, and add the folder to python.autocomplete.extraPaths (In my case, the one that I told you above)

3- Add the maya module to python.autocomplete.preloadModules

4- Try restarting VSCode and importing the module with the following snippet:

import maya.cmds as cmds

Let me know if you need some more info!

Thanks for this amazing Extension and for your hard work!

Schronuman commented 6 years ago

I have met the same situation using the numpy. Even though I have added it to the python.autocomplete.preloadModules , the autocomplete still has a 2-4 seconds lag. Such a problem is really painful.

brettcannon commented 6 years ago

Yes, it looks like preloading isn't doing anything.

TylerGubala commented 6 years ago

I'm trying to get Blender as a Python module to work and am facing an issue where I can't get the autocompletion and linting to work in Visual Studio Code.

If you pip install bpy into a venv and set your python interpriter to the venv's interpriter you will see what I mean.

import bpy

import bpy.type[...]
[Loading...]

but it never loads the auto completion. As soon as you put in the dot between bpy and start typing types it should intellisense, but it's not working for some reason.

Is there something I'm doing wrong?

The bpy.pyd is working fine in the interactive interpriter.

OS: Windows 10 Pro 64 bit Python Version: Python 3.6.5 64bit

asierralozano commented 6 years ago

Does this new languageServer fix this issue? Or it is not related at all?

brettcannon commented 6 years ago

@asierralozano it isn't related

lucasrabelo commented 6 years ago

I have the same problem. Vs Code shows a lot of code but none related to the module. And the annoying part is if you press enter, it will import a lot of nonsense

ssunno commented 6 years ago

I have the same issue using tensorflow. It seems to "python.autoComplete.preloadModules": ["tensorflow"] do not working properly.

brettcannon commented 6 years ago

We should make sure to check if both Jedi and the language server exhibit this bug.

DonJayamanne commented 6 years ago

I can confirm we're procecssing preloadModules correctly and the fact that these settings are being passed onto Jedi correctly (I.e. jedi is in fact pre-loading them). Looks like Jedi is slow at pre-loading this completion list.

We should make sure to check if language server exhibit this bug.

Language server does not utilize this setting, as it doesn't have the ability to pre-load modules. I've tested this with the language server and it seems to work very well.

E.g. intellisense for tensorflow takes approx 8 seconds on my Mac with Jedi, however with the new language server it takes ~1 second.

@ssunno @asierralozano @TylerGubala @TylerGubala Please could you try the new language server. Please install the latest development version of the extension from here and update your settings.json as follows "python.jediEnabled": false

brettcannon commented 6 years ago

If Jedi is doing the right thing but isn't meeting people's expectations and the setting makes no sense for the language server then we should probably consider dropping the setting (we can either fully deprecate it or simply remove the setting visibly so those that have it can continue to have it work for them).

DonJayamanne commented 6 years ago

Agreed.

asierralozano commented 6 years ago

Hello!

I was trying the newest language server, and it seems that, for example, with the Autodesk Maya module, VSCode is showing up the autocomplete suggestions very quickly!

So it looks like it is a Jedi issue, and with the newest language server is working so smooth!

SheepDomination commented 6 years ago

If understood correctly I have to set "python.jediEnabled": false within the user settings.json file; but, how are modules still being loaded if "python.autoComplete.preloadModules": is not used ?

brettcannon commented 6 years ago

@SheepDomination "python.jediEnabled": false turns on the new language server. Modules are still loaded because both Jedi and the language server look at sys.path and what code you import for where to look. The preloadModules was just an optimization to automatically process files even if you didn't open a file that imported them.