Skip to content

Unresolved Import #5563

Closed
Closed

Description

@Anti-Distinctlyminty

Environment data

  • VS Code version: 1.33.1
  • Extension version (available under the Extensions sidebar): 2019.4.12954
  • OS and version: Windows_NT x64 10.0.17134
  • Python version (& distribution if applicable, e.g. Anaconda): 2.7.11 64-bit

Expected behaviour

With python.autoComplete.extraPaths set correctly, modules should import without issue.

Actual behaviour

I receive a Unresolved import 'moduleName' when using syntax of the form
import workspace_folder.module as alt_name
and if the .code-workspace file is in the same directory.
e.g.
Code_2019-05-06_15-24-33

Steps to reproduce:

  1. Extract the following to a suitable location:
    myLib.zip
  2. Inside myLib, open the Import_Bug.code-workspace file
  3. Go to workspace settings and change the python.autoComplete.extraPaths to the folder containing myLib.
  4. open libFunctions.py and see that import myLib.importMe as im has an unresolved import error.

I am aware that the organization of this workspace is sub-optimal, with the code-workspace file being inside the python library folder. However, with all paths being set correctly, the import should still succeed.

Logs

Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

Blank.

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

Blank.

Activity

  1. ghost added
    triage-neededNeeds assignment to the proper sub-team
    on May 6, 2019
  2. luabud commented on May 9, 2019

    @luabud
    Member
  3. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on May 9, 2019
  4. AlexanderSher commented on May 9, 2019

    @AlexanderSher

    There are two issues with this workspace:

    • Workspace file itself contains path:
    "folders": [
        {
            "path": "."
        }
    ]
    

    which defines workspace root as workspace_folder. path has priority over python.autoComplete.extraPaths setting, so if extra path is parent folder to the path folder, it will be ignored for any module inside path. To fix the workspace, you can change path to ...

  5. locked as resolved and limited conversation to collaborators on Jun 2, 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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions