Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reportMissingImports : Even if the module is successfully installed, a warning will still be displayed in the Error List window #7068

Open
linette-zyy opened this issue Jul 4, 2022 · 23 comments · Fixed by #7401
Assignees
Labels

Comments

@linette-zyy
Copy link

Environment
image

Steps to Reproduce
1.Create a Flask Web Project.
2.Click Create virtual environment( Make sure Flask was successfully installed ).
image
3.Reload the Project.

Expected behavior
After Flask is successfully installed, no errors or warnings will be displayed.

Actual behavior
image

Pylance Output info

Info: (11928) Pylance language server 2022.6.30 (pyright 212d1465) starting
Info: (11928) Server root directory: c:\program files\microsoft visual studio\2022\preview\common7\ide\extensions\microsoft\python\core\pylance\dist
Log: Notebook support: Legacy
Info: Un-registering request handler for f75843bf-a321-48d6-a068-5f855d760690 failed.
Error: (11928) Error reading settings: TypeError: Cannot read properties of undefined (reading 'variableTypes')
Info: (11928) No configuration file found.
Info: (11928) No pyproject.toml file found.
Info: (11928) Setting pythonPath for service "FlaskWebProject7": "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\python.exe"
Warning: (11928) stubPath C:\Users\wangjun\source\repos\FlaskWebProject7\FlaskWebProject7\typings is not a valid directory.
Info: (11928) Assuming Python version 3.9
Info: (11928) Assuming Python platform Windows
Info: (11928) Searching for source files
Info: (11928) Found 3 source files
Info: (11928) Background analysis(1) root directory: c:\program files\microsoft visual studio\2022\preview\common7\ide\extensions\microsoft\python\core\pylance\dist
Info: (11928) Background analysis(1) started
Info: (11928) Searching for source files
Info: (11928) Auto-excluding C:\Users\wangjun\source\repos\FlaskWebProject7\FlaskWebProject7\env
Info: (11928) Found 3 source files
Info: (8788) Pylance language server 2022.6.30 (pyright 212d1465) starting
Info: (8788) Server root directory: c:\program files\microsoft visual studio\2022\preview\common7\ide\extensions\microsoft\python\core\pylance\dist
Log: Notebook support: Legacy
Info: (8788) No pyproject.toml file found.
Warning: (8788) stubPath typings is not a valid directory.
Info: (8788) Assuming Python platform Windows
Info: (8788) Searching for source files
Info: (8788) No source files found.
Info: (8788) Background analysis(1) root directory: c:\program files\microsoft visual studio\2022\preview\common7\ide\extensions\microsoft\python\core\pylance\dist
Info: (8788) Background analysis(1) started
Info: (15044) Pylance language server 2022.6.30 (pyright 212d1465) starting
Info: (15044) Server root directory: c:\program files\microsoft visual studio\2022\preview\common7\ide\extensions\microsoft\python\core\pylance\dist
Log: Notebook support: Legacy
Info: (15044) No pyproject.toml file found.
Warning: (15044) stubPath typings is not a valid directory.
Info: (15044) Assuming Python platform Windows
Info: (15044) Searching for source files
Info: (15044) No source files found.
Info: (15044) Background analysis(1) root directory: c:\program files\microsoft visual studio\2022\preview\common7\ide\extensions\microsoft\python\core\pylance\dist
Info: (15044) Background analysis(1) started
Info: (5832) Pylance language server 2022.6.30 (pyright 212d1465) starting
Info: (5832) Server root directory: c:\program files\microsoft visual studio\2022\preview\common7\ide\extensions\microsoft\python\core\pylance\dist
Log: Notebook support: Legacy
Info: (7592) Pylance language server 2022.6.30 (pyright 212d1465) starting
Info: (7592) Server root directory: c:\program files\microsoft visual studio\2022\preview\common7\ide\extensions\microsoft\python\core\pylance\dist
Log: Notebook support: Legacy
Info: (7592) No pyproject.toml file found.
Warning: (7592) stubPath typings is not a valid directory.
Info: (7592) Assuming Python platform Windows
Info: (7592) Searching for source files
Info: (7592) No source files found.
Info: (7592) Background analysis(1) root directory: c:\program files\microsoft visual studio\2022\preview\common7\ide\extensions\microsoft\python\core\pylance\dist
Info: (7592) Background analysis(1) started
Info: (4564) Pylance language server 2022.6.30 (pyright 212d1465) starting
Info: (4564) Server root directory: c:\program files\microsoft visual studio\2022\preview\common7\ide\extensions\microsoft\python\core\pylance\dist
Log: Notebook support: Legacy
Info: (4564) No pyproject.toml file found.
Warning: (4564) stubPath typings is not a valid directory.
Info: (4564) Assuming Python platform Windows
Info: (4564) Searching for source files
Info: (4564) No source files found.
Info: (4564) Background analysis(1) root directory: c:\program files\microsoft visual studio\2022\preview\common7\ide\extensions\microsoft\python\core\pylance\dist
Info: (4564) Background analysis(1) started
Info: (6244) Pylance language server 2022.6.30 (pyright 212d1465) starting
Info: (6244) Server root directory: c:\program files\microsoft visual studio\2022\preview\common7\ide\extensions\microsoft\python\core\pylance\dist
Log: Notebook support: Legacy
Info: (6244) No pyproject.toml file found.
Warning: (6244) stubPath typings is not a valid directory.
Info: (6244) Assuming Python platform Windows
Info: (6244) Searching for source files
Info: (6244) No source files found.
Info: (6244) Background analysis(1) root directory: c:\program files\microsoft visual studio\2022\preview\common7\ide\extensions\microsoft\python\core\pylance\dist
Info: (6244) Background analysis(1) started
Info: (14756) Pylance language server 2022.6.30 (pyright 212d1465) starting
Info: (14756) Server root directory: c:\program files\microsoft visual studio\2022\preview\common7\ide\extensions\microsoft\python\core\pylance\dist
Log: Notebook support: Legacy
Info: (14756) No pyproject.toml file found.
Warning: (14756) stubPath typings is not a valid directory.
Info: (14756) Assuming Python platform Windows
Info: (14756) Searching for source files
Info: (14756) No source files found.
Info: (14756) Background analysis(1) root directory: c:\program files\microsoft visual studio\2022\preview\common7\ide\extensions\microsoft\python\core\pylance\dist
Info: (14756) Background analysis(1) started

@linette-zyy
Copy link
Author

#6713
today's build is vs 2022 Preview 4, but it doesn't be fixed

@excubo-jg
Copy link

I think the recent comments on the closed issue #6713 also relate to this. Something seems to break once projects use flask which causes quite annoying erroneous knock-on warnings and falsely flagging modules and variables as being unused. The latter problem seems to go away once VS is restarted.

@earnshaw
Copy link

earnshaw commented Jan 4, 2023

I am also getting the same issues - and I'm not even using flask. Be good to get this fixed as its annoying to keep seeing:

image

This was in version of 17.4.1 of Visual Studio Professional

@earnshaw
Copy link

earnshaw commented Jan 4, 2023

Still a problem at 17.4.3 of Visual Studio Pro.

@excubo-jg
Copy link

I agree the problem is not limited to projects using flask. Probably related to #7274 as the "X could not be resolved" warnings are not reported when the CLI-version of pyright is run on the project.

@axelande
Copy link

axelande commented Feb 6, 2023

Still a problem at 17.4.4 of Visual Studio

@earnshaw
Copy link

earnshaw commented Feb 6, 2023

Whats the betting that it won't be fixed in the next version.

@supershopping
Copy link

Still having issue on Version 17.5.3.

@flexorx
Copy link

flexorx commented May 8, 2023

An issue on a fresh environment and newest VS-2022 (17.5.5). Works well in VS-2019; works in Version 17.6.0 Preview 6.0.

@StellaHuang95
Copy link
Contributor

@bschnurr This seems to still repro in the recent versions, shall we re-open it?

@judej
Copy link
Contributor

judej commented Aug 30, 2023

We are still getting reports of this issue

@judej judej reopened this Aug 30, 2023
@judej judej removed the fixed in next version A fix has been implemented an will appear in an upcoming version label Aug 30, 2023
@StellaHuang95 StellaHuang95 removed their assignment Sep 27, 2023
@bschnurr
Copy link
Member

I see this fixed in latest. it should be in the newest dogfood build

@axelande
Copy link

axelande commented Jan 28, 2024

What do you mean with the newest dogfood build? When I tried with an updated version I got redirected here instead of my venv (for a few packages that was in pylance, for the other I get no redirect/help but the missing import underline is gone :)):

image

Could it be some issue with my .pyproj file?
image

(All python files are in the first ItemGroup and there are no "python interpreter paths" defined in that ItemGroup)

Microsoft Visual Studio Community 2022
Version 17.8.5
VisualStudio.17.Release/17.8.5+34511.84
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Community

Visual C++ 2022 00482-90000-00000-AA553
Microsoft Visual C++ 2022

ASP.NET and Web Tools 17.8.358.6298
ASP.NET and Web Tools

Azure App Service Tools v3.0.0 17.8.358.6298
Azure App Service Tools v3.0.0

C# Tools 4.8.0-7.23572.1+7b75981cf3bd520b86ec4ed00ec156c8bc48e4eb
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Cookiecutter 17.0.23262.1
Provides tools for finding, instantiating and customizing templates in cookiecutter format.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

NuGet Package Manager 6.8.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Python - Profiling support 17.0.23262.1
Profiling support for Python projects.

Python - VC Project Support 17.0.23055.1
Provides support for launching C++ projects with Python debugging enabled.

Python with Pylance 17.0.23262.1
Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.

Visual Basic Tools 4.8.0-7.23572.1+7b75981cf3bd520b86ec4ed00ec156c8bc48e4eb
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.

@bschnurr
Copy link
Member

bschnurr commented Jan 29, 2024

Preview 1 build
image

@axelande
Copy link

axelande commented Feb 14, 2024

Still the same problem for me with Pylance 17.0.24026.1:
I think that the problem is related to paths in the .pyproj file.

I've played around and created a new project, which works great.

This is basically the folder structure that I'm working with:

my_project
- code
- - pythoncode
- - - folder_a
- - - - file_a.py
- msvc
- - python_proj
- - - python_proj.pyproj
- venv

Very complicated but it has it reasons...

In the python_proj.pyproj I have (among a lot of others):

 ....
    <ProjectHome>..\..\code\</ProjectHome>
    <SearchPath>..\</SearchPath>
      ...
    <InterpreterId>MSBuild|venv|$(MSBuildProjectFullPath)</InterpreterId>
  <ItemGroup>
   <Content Include="pythoncode\folder_a\file_a.py" />
  </ItemGroup>
  <ItemGroup>
    <Interpreter Include="..\venv\">
      <Id>venv</Id>
      <Version>3.11.1</Version>
      <Description>venv (Python 3.11.1) my_project</Description>
      <InterpreterPath>Scripts\python.exe</InterpreterPath>
      <WindowsInterpreterPath>Scripts\pythonw.exe</WindowsInterpreterPath>
      <LibraryPath>Lib\</LibraryPath>
      <PathEnvironmentVariable>PYTHONPATH</PathEnvironmentVariable>
      <Architecture>x64</Architecture>
    </Interpreter>
  </ItemGroup>

The code works and I can run it, debug it etc. etc. but pylance doesn't find the venv with this structure, where does it search or how can I specify where it should search for a venv?

@StellaHuang95
Copy link
Contributor

@bschnurr Looks like it still repros, so I just reopened the issue.

@axelande
Copy link

Anything I can do to help fix this issue? (Or change paths in my .pyproj file to help the Intellisense?)

@fmelfa
Copy link

fmelfa commented Feb 24, 2024

I just installed Microsoft Visual Studio Professional 2022 update to Version 17.8.7 and it resolve the issue
Python - Django support 17.0.23262.1
Python - Profiling support 17.0.23262.1
Python - VC Project Support 17.0.23055.1
Python with Pylance 17.0.23262.1
Visual Studio IntelliCode 2.2

image

@axelande
Copy link

Any news while working with a complex folder structure?

@axelande
Copy link

Is there any possibility to tell the intellisense where to look for the venv?

@bschnurr
Copy link
Member

bschnurr commented Oct 8, 2024

appears to be fixed
Image

@bschnurr bschnurr closed this as completed Oct 8, 2024
@axelande
Copy link

axelande commented Oct 9, 2024

I tried to get the latest preview version, however still the same issue. @bschnurr can you try to set up a project with the folder structure like I described in the post from 14 feb and see if that works for you?

@axelande
Copy link

I've pinpointed that I can't get the intellisense to work in VisualStudio due to my folder structure, is there any way to help the intellisense to find the correct Python environment? The VisualStudio runtime understand it but not the intellisense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants