question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Language Server] "Unable to resolve module" for app project

See original GitHub issue

Environment data

  • VS Code version: Version 1.25.1 (1.25.1)
  • Extension version (available under the Extensions sidebar): 2018.7.0
  • OS and version: macOS 10.13.6
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.3
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): virtualenv
  • Relevant/affected Python packages and their versions: XXX

Actual behavior

I have a few directories that form my python workspace. Each directory is a separate python project (either app, that’s executed, or library, that has setup.py and is installed) with a separate env configured inside vscode. I’ve turned on new “language server” feature.

Imports from my app are underlined and say “Unable to resolve <module>. Intellisense may be missing.” Imports from my libs work fine.

Expected behavior

I’d like language server to process apps as well (autocomplete, goto, etc.)

Logs

Starting Microsoft Python language server.
[Info  - 10:43:22 PM] Created Microsoft.PythonTools.Interpreter.Ast.AstPythonInterpreter instance from Microsoft.PythonTools.Interpreter.Ast.AstPythonInterpreterFactory
Initializing for /Users/yevhen/.virtualenvs/<app_project>/bin/python

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:23
  • Comments:42 (9 by maintainers)

github_iconTop GitHub Comments

13reactions
eikonomegacommented, Jul 19, 2018

I’m also having the same issue.

VS Code version: Version 1.26.0-insider
Extension version (available under the Extensions sidebar): 2018.7.0
OS and version: macOS 10.13.6
Python version (& distribution if applicable, e.g. Anaconda): 2.7.15
Type of virtual environment used (N/A | venv | virtualenv | conda | ...): pyenv
Relevant/affected Python packages and their versions: XXX

All relative imports within my own code (non-3rd party) are marked as unable to resolve module. Jedi handles the code correctly.

image

Logs

Starting Microsoft Python language server.
[Info  - 16:18:10] Created Microsoft.PythonTools.Interpreter.Ast.AstPythonInterpreter instance from Microsoft.PythonTools.Interpreter.Ast.AstPythonInterpreterFactory
Initializing for /Users/panda/.pyenv/versions/wellbeingatwork/bin/python
##########Linting Output - flake8##########
##########Linting Output - flake8##########
##########Linting Output - flake8##########
##########Linting Output - flake8##########
12reactions
alnvdlcommented, Jul 23, 2018

I got this down to a minimal set of steps:

  1. Create a project structure like this

     project
         package
             __init__.py
         test.py
         env
    

    package is a package with an empty __init__.py file. test.py tries to import package. env is a virtual environment (python3 -m venv env)

  2. Open this folder in fresh install of VSCode 1.25 and vscode-python 2018.7.0 as a single-folder workspace (just Open folder), with Jedi disabled. Set the Python interpreter to the one in the virtual environment.

  3. You’ll see the “IntelliSense may be missing” message for the import package line.

To be honest, the virtual environment doesn’t make a difference, I just included it because it’s one more place to look for the package in addition to the system libs and our own packages, and it isn’t working either. I tested this on Debian 9, but I don’t think it makes a difference (others have different setups). Import, auto-completion and signatures for global packages (e.g.: datetime, json) work just fine.

As I said in my previous message, adding folders manually in python.autoComplete.extraPaths makes it work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to Resolve Module in React Native App - Stack Overflow
To solve it you need to view the mentioned file and change the file location to the correct location. Share.
Read more >
Language Server Extension Guide - Visual Studio Code
Learn how to create Language Servers to provide rich language features in Visual Studio Code.
Read more >
Environment - You.com
react native - EXPO: Unable to resolve module '. ... asyncGeneratorStep (/Users/pierrebresson/Documents/Git/nmf-app/node_modules/metro/src/Server.js:99:24) ...
Read more >
typescript-language-server - npm
Start using typescript-language-server in your project by running `npm i ... module names to be resolved in the initial completions request.
Read more >
Using Visual Studio Code | Manual - Deno
We realize that not every project you might edit with vscode is a Deno ... for Deno APIs as well as the ability...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found