Skip to content

Auto-Completion with Language Server does not find certain built-in modules when using import #3969

Description

I'm not a python expert, so I hope this is the an appropriate place to comment on this issue.

Environment data

  • VS Code version: 1.31.0-insider
  • Extension version (available under the Extensions sidebar): 2018.12.1
  • OS and version: Windows 10.0.17763.253
  • Python version (& distribution if applicable, e.g. Anaconda): 2.7.11
  • Type of virtual environment used: Not virtual, but using Python provided by Autodesk Maya

Expected behaviour

When using the Python Language Server for auto-completion, intellisense should be provided for built-in modules (eg: os, json, binascii, etc).

Actual behaviour

Intellisense is not shown for many (but not all) built-in modules. Examples of modules that don't have intellisense are os, json, and collections. Other do show intellisense, like binascii.
Pylint reports "unresolved import" for the 'missing' modules. However, scripts containing these modules run normally.
When using the Jedi auto-completion system, all these modules have the expected intellisesnse.
If scripts

Steps to reproduce:

I'm using Python distributed as part of Autodesk Maya. I've set up "python.pythonPath" and "python.autoComplete.extraPath" so that auto complete is working for my own modules and for the modules provided by Maya.

  1. Create a python file in VS Code with the line "import os".
  2. Attempt to us the os module in the file.
  3. No intellisense appears. Pylint reports the modules as unresolved.
  4. Switch to Jedi auto-complete. Reload VS Code.
  5. Intellisense shows up for os module; Pylint no longer reports an error.

Logs

Output window doesn't mention anything other than the initialization message and pylint "rating".

Again, I'm not an expert, but from what I can tell, the Jedi auto-complete comes from modules that are stored in a zip file called python27.zip that resides in the same folder as the python executable (called 'mayapy.exe'). I wonder if the Jedi system is capable of extracting intellisense from modules stored in this archive while the Python Language Server is not.

In the image below, the module binascii has intellisense, but os, json, collections, and gzip were not able to be resolved.

image

Activity

  1. ghost added
    triage-neededNeeds assignment to the proper sub-team
    on Jan 12, 2019
  2. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on Jan 14, 2019
  3. DonJayamanne commented on Jan 14, 2019

    @DonJayamanne
    • Please could you ensure Jedi is disabled, then reload VS Code
    • Replicate the above issue
    • Copy and past the contents of your Python output panel into this issue.
      • Go into the command View: Toggle Panel
      • Select the Output tab
      • From the dropdown select Python
  4. added
    info-neededIssue requires more information from poster
    bugIssue identified by VS Code Team member as probable bug
    area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.
    on Jan 14, 2019
  5. michaeldaw commented on Jan 16, 2019

    @michaeldaw
    Author

    Don Jayamanne (@DonJayamanne) thanks for getting back to me.

    I followed the steps you outlined. The issue I described is now happening again. It doesn't look there is anything pertinent in the Python output log. Here is it's contents:

    Starting Microsoft Python language server.
    ##########Linting Output - pylint##########


    Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

    Microsoft Python Language Server version 0.1.75.0
    Initializing for C:/Program Files/Autodesk/Maya2018/bin/mayapy.exe
    ##########Linting Output - pylint##########


    Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

    ##########Linting Output - pylint##########


    Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
    image

    Pylint still shows the imports I mentioned as being unresolved:
    image

  6. DonJayamanne commented on Feb 4, 2019

    @DonJayamanne

    Michael Daw (@michaeldaw) Please could you test this once again with the latest version of the extension. This will ensure you are using the latest version of the Language Server as well.

  7. michaeldaw commented on Feb 4, 2019

    @michaeldaw
    Author

    I'll do so as soon as I can. Thanks.

  8. michaeldaw commented on Feb 5, 2019

    @michaeldaw
    Author

    I'm currently on the latest version. 2019.1.0.

    Should I bring this up on the Python Language Server repo?

  9. luabud commented on Sep 11, 2019

    @luabud
    Member

    Fixed upstream

  10. locked as resolved and limited conversation to collaborators on Sep 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.feature-requestRequest for new features or functionality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions