microsoft / python-language-server

Microsoft Language Server for Python
Apache License 2.0
912 stars 133 forks source link

numpy packages misses **all** functions after recent update #1847

Open AeneasZhu opened 4 years ago

AeneasZhu commented 4 years ago

image

image

After installing latest python-language-server, vs intellicode misses most numpy funcions.

image

MikhailArkhipov commented 4 years ago

What happens if you use same code in plain Python file? Could you try that and supply trace log as listed in https://github.com/microsoft/python-language-server/blob/master/TROUBLESHOOTING.md#filing-an-issue - thanks!

rsokl commented 4 years ago

I am having the same issue. None of numpy's functions or methods appear among auto-completion items.

Basic Information

Code Snippet

import numpy
x = numpy.array([1])
x.sum

Language Server Trace

Completions in file:///home/user/PolloPatches/tests/test_rotation.py at (2, 5)
Analysis version 1469 of 1 entries has started.
Analysis of tests.test_rotation (User) on depth 0 completed in 0.61 ms.
IntelliCode identified no likely completion items.
Analysis complete: 1 modules in 3.21 ms.
Analysis version 1469 of 1 entries has been completed in 0.84 ms.
Code Action in file:///home/user/PolloPatches/tests/test_rotation.py at (2, 5) - (2, 5)
Hover in file:///home/user/PolloPatches/tests/test_rotation.py at (1, 11)

Conda Environment (.yml)

name: just_numpy
channels:
  - defaults
dependencies:
  - _libgcc_mutex=0.1=main
  - blas=1.0=mkl
  - ca-certificates=2020.1.1=0
  - certifi=2020.4.5.1=py37_0
  - intel-openmp=2020.0=166
  - ld_impl_linux-64=2.33.1=h53a641e_7
  - libedit=3.1.20181209=hc058e9b_0
  - libffi=3.2.1=hd88cf55_4
  - libgcc-ng=9.1.0=hdf63c60_0
  - libgfortran-ng=7.3.0=hdf63c60_0
  - libstdcxx-ng=9.1.0=hdf63c60_0
  - mkl=2020.0=166
  - mkl-service=2.3.0=py37he904b0f_0
  - mkl_fft=1.0.15=py37ha843d7b_0
  - mkl_random=1.1.0=py37hd6b4f25_0
  - ncurses=6.2=he6710b0_0
  - numpy=1.18.1=py37h4f9e942_0
  - numpy-base=1.18.1=py37hde5b4d6_1
  - openssl=1.1.1f=h7b6447c_0
  - pip=20.0.2=py37_1
  - python=3.7.7=hcf32534_0_cpython
  - readline=8.0=h7b6447c_0
  - setuptools=46.1.3=py37_0
  - six=1.14.0=py37_0
  - sqlite=3.31.1=h7b6447c_0
  - tk=8.6.8=hbc83047_0
  - wheel=0.34.2=py37_0
  - xz=5.2.5=h7b6447c_0
  - zlib=1.2.11=h7b6447c_3
prefix: /home/user/anaconda3/envs/just_numpy
MikhailArkhipov commented 4 years ago

Can you please attach complete log with "python.analysis.logLevel": "Trace"?

rsokl commented 4 years ago

I set the log level to trace and got the log that I included in my message above. I didn't see any additional information.

MikhailArkhipov commented 4 years ago

Complete log includes LS startup, configuration, etc. Like

[Info  - 10:11:10 AM] GetCurrentSearchPaths C:\Python3\python.exe 
[Info  - 10:11:10 AM] Interpreter search paths:
[Info  - 10:11:10 AM]     c:\python3\dlls
[Info  - 10:11:10 AM]     c:\python3\lib
[Info  - 10:11:10 AM]     c:\python3
[Info  - 10:11:10 AM]     c:\users\...\appdata\roaming\python\python36\site-packages
[Info  - 10:11:10 AM]     c:\python3\lib\site-packages
[Info  - 10:11:10 AM] User search paths:
[Info  - 10:11:16 AM] Initializing for C:\Python3\python.exe
[Info  - 10:11:16 AM] Analysis caching mode: None.

Analysis version 1469 of 1 entries has started. looks like analysis is complete - so we'd like to see how did it run from the start.

rsokl commented 4 years ago
[Info  - 12:49:44 PM] Analysis cache path: /home/user/.cache/Microsoft/Python Language Server
[Info  - 12:49:44 PM] Microsoft Python Language Server version 0.5.45.0
[Info  - 12:49:44 PM] Workspace root: /home/user/PolloPatches
[Info  - 12:49:44 PM] GetCurrentSearchPaths /home/user/anaconda3/envs/hardnet/bin/python 
[Info  - 12:49:44 PM] Interpreter search paths:
[Info  - 12:49:44 PM]     /home/user/anaconda3/envs/hardnet/lib/python3.7
[Info  - 12:49:44 PM]     /home/user/anaconda3/envs/hardnet/lib/python3.7/lib-dynload
[Info  - 12:49:44 PM]     /home/user/anaconda3/envs/hardnet/lib/python3.7/site-packages
[Info  - 12:49:44 PM]     /home/user/liveplot/src
[Info  - 12:49:44 PM]     /home/user/HardNet/src
[Info  - 12:49:44 PM]     /home/user/PhotoSynth/src
[Info  - 12:49:44 PM]     /home/user/Hpatches
[Info  - 12:49:44 PM]     /home/user/retina_parser/src
[Info  - 12:49:44 PM]     /home/user/DataSets
[Info  - 12:49:44 PM]     /home/user/d2-net
[Info  - 12:49:44 PM]     /home/user/r2d2/src
[Info  - 12:49:44 PM] User search paths:
[Info  - 12:49:46 PM] Initializing for /home/user/anaconda3/envs/hardnet/bin/python
[Info  - 12:49:46 PM] Analysis caching mode: None.
[Error - 12:54:48 PM] Request textDocument/documentHighlight failed.
  Message: Specified argument was out of the range of valid values. (Parameter 'line must be greater than or equal to 1')
  Code: -32000 
   at Microsoft.Python.Core.Text.SourceLocation.ValidateLocation(Int32 index, Int32 line, Int32 column) in E:\A\_work\1\s\src\Core\Impl\Text\SourceLocation.cs:line 68
   at Microsoft.Python.Analysis.Types.LocationInfo.get_Span() in E:\A\_work\1\s\src\Analysis\Ast\Impl\Types\Definitions\LocationInfo.cs:line 60
   at Microsoft.Python.LanguageServer.Sources.DefinitionSourceBase.TryFromVariable(String name, IDocumentAnalysis analysis, SourceLocation location, Node statement, ILocatedMember& definingMember) in E:\A\_work\1\s\src\LanguageServer\Impl\Sources\DefinitionSource.cs:line 287
   at Microsoft.Python.LanguageServer.Sources.DefinitionSourceBase.FindDefinition(IDocumentAnalysis analysis, SourceLocation location, ILocatedMember& definingMember) in E:\A\_work\1\s\src\LanguageServer\Impl\Sources\DefinitionSource.cs:line 106
   at Microsoft.Python.LanguageServer.Sources.DocumentHighlightSource.DocumentHighlightAsync(Uri uri, SourceLocation location, CancellationToken cancellationToken) in E:\A\_work\1\s\src\LanguageServer\Impl\Sources\DocumentHighlightSource.cs:line 49
   at Microsoft.Python.LanguageServer.Implementation.LanguageServer.DocumentHighlight(JToken token, CancellationToken cancellationToken) in E:\A\_work\1\s\src\LanguageServer\Impl\LanguageServer.cs:line 219
[Error - 12:55:01 PM] Request textDocument/documentHighlight failed.
  Message: Specified argument was out of the range of valid values. (Parameter 'line must be greater than or equal to 1')
  Code: -32000 
   at Microsoft.Python.Core.Text.SourceLocation.ValidateLocation(Int32 index, Int32 line, Int32 column) in E:\A\_work\1\s\src\Core\Impl\Text\SourceLocation.cs:line 68
   at Microsoft.Python.Analysis.Types.LocationInfo.get_Span() in E:\A\_work\1\s\src\Analysis\Ast\Impl\Types\Definitions\LocationInfo.cs:line 60
   at Microsoft.Python.LanguageServer.Sources.DefinitionSourceBase.TryFromVariable(String name, IDocumentAnalysis analysis, SourceLocation location, Node statement, ILocatedMember& definingMember) in E:\A\_work\1\s\src\LanguageServer\Impl\Sources\DefinitionSource.cs:line 287
   at Microsoft.Python.LanguageServer.Sources.DefinitionSourceBase.FindDefinition(IDocumentAnalysis analysis, SourceLocation location, ILocatedMember& definingMember) in E:\A\_work\1\s\src\LanguageServer\Impl\Sources\DefinitionSource.cs:line 106
   at Microsoft.Python.LanguageServer.Sources.DocumentHighlightSource.DocumentHighlightAsync(Uri uri, SourceLocation location, CancellationToken cancellationToken) in E:\A\_work\1\s\src\LanguageServer\Impl\Sources\DocumentHighlightSource.cs:line 49
   at Microsoft.Python.LanguageServer.Implementation.LanguageServer.DocumentHighlight(JToken token, CancellationToken cancellationToken) in E:\A\_work\1\s\src\LanguageServer\Impl\LanguageServer.cs:line 221
[Info  - 1:21:51 PM] Analysis caching mode: None.
[Info  - 1:21:53 PM] Analysis cache path: /home/user/.cache/Microsoft/Python Language Server
[Info  - 1:21:53 PM] Microsoft Python Language Server version 0.5.45.0
[Info  - 1:21:53 PM] Workspace root: /home/user/PolloPatches
[Info  - 1:21:53 PM] GetCurrentSearchPaths /home/user/anaconda3/envs/just_numpy/bin/python 
[Info  - 1:21:53 PM] Interpreter search paths:
[Info  - 1:21:53 PM]     /home/user/anaconda3/envs/just_numpy/lib/python3.7
[Info  - 1:21:53 PM]     /home/user/anaconda3/envs/just_numpy/lib/python3.7/lib-dynload
[Info  - 1:21:53 PM]     /home/user/anaconda3/envs/just_numpy/lib/python3.7/site-packages
[Info  - 1:21:53 PM] User search paths:
[Info  - 1:21:54 PM] Initializing for /home/user/anaconda3/envs/just_numpy/bin/python
[Info  - 1:21:54 PM] Analysis caching mode: None.
[Info  - 1:22:09 PM] Analysis caching mode: None.
Code Action in file:///home/user/PolloPatches/pollo_patches/utils/rotate.py at (18, 16) - (18, 16)
Code Action in file:///home/user/PolloPatches/pollo_patches/utils/rotate.py at (18, 16) - (18, 16)
Code Action in file:///home/user/PolloPatches/tests/throwaway.py at (0, 0) - (0, 0)
Code Action in file:///home/user/PolloPatches/tests/throwaway.py at (2, 5) - (2, 5)
Analysis of tests.throwaway (User) queued. Dependencies: numpy
Analysis version 1384 of 1 entries has started.
Analysis of tests.throwaway (User) on depth 0 completed in 8.75 ms.
Analysis complete: 1 modules in 15.1 ms.
Analysis version 1384 of 1 entries has been completed in 9.47 ms.
Code Action in file:///home/user/PolloPatches/tests/throwaway.py at (2, 2) - (2, 2)
Code Action in file:///home/user/PolloPatches/tests/throwaway.py at (2, 2) - (2, 2)
Analysis of tests.throwaway (User) queued. Dependencies: numpy
Analysis version 1385 of 1 entries has started.
Analysis of tests.throwaway (User) on depth 0 completed in 2.23 ms.
Analysis complete: 1 modules in 8.3 ms.
Analysis version 1385 of 1 entries has been completed in 3.3 ms.
Completions in file:///home/user/PolloPatches/tests/throwaway.py at (2, 3)
Analysis of tests.throwaway (User) queued. Dependencies: numpy
Analysis version 1386 of 1 entries has started.
Analysis of tests.throwaway (User) on depth 0 completed in 0.7 ms.
Analysis complete: 1 modules in 2.15 ms.
Analysis version 1386 of 1 entries has been completed in 0.85 ms.
IntelliCode identified 5 likely completion items.
Code Action in file:///home/user/PolloPatches/tests/throwaway.py at (2, 4) - (2, 4)
Analysis of tests.throwaway (User) queued. Dependencies: numpy
Analysis version 1387 of 1 entries has started.
Analysis of tests.throwaway (User) on depth 0 completed in 2.73 ms.
Analysis complete: 1 modules in 7.01 ms.
Analysis version 1387 of 1 entries has been completed in 3.41 ms.
Code Action in file:///home/user/PolloPatches/tests/throwaway.py at (2, 5) - (2, 5)
Code Action in file:///home/user/PolloPatches/tests/throwaway.py at (2, 5) - (2, 5)
MikhailArkhipov commented 4 years ago

Looks like

Message: Specified argument was out of the range of valid values. (Parameter 'line must be greater than or equal to 1')
  Code: -32000 
   at Microsoft.Python.Core.Text.SourceLocation.ValidateLocation(Int32 index, Int32 line, Int32 column) in E:\A\_work\1\s\src\Core\Impl\Text\SourceLocation.cs:line 68
   at Microsoft.Python.Analysis.Types.LocationInfo.get_Span() in E:\A\_work\1\s\src\Analysis\Ast\Impl\Types\Definitions\LocationInfo.cs:line 60
   at Microsoft.Python.LanguageServer.Sources.DefinitionSourceBase.TryFromVariable(String name, IDocumentAnalysis analysis, SourceLocation location, Node statement, ILocatedMember& definingMember) in E:\A\_work\1\s\src\LanguageServer\Impl\Sources\DefinitionSource.cs:line 287
   at Microsoft.Python.LanguageServer.Sources.DefinitionSourceBase.FindDefinition(IDocumentAnalysis analysis, SourceLocation location, ILocatedMember& definingMember) in E:\A\_work\1\s\src\LanguageServer\Impl\Sources\DefinitionSource.cs:line 106

crashed first launch, but its a separate issue. LS restarted, but I don't see any numpy analysis running...

rsokl commented 4 years ago
Analysis of tests.throwaway (User) queued. Dependencies: numpy
Analysis version 1384 of 1 entries has started.
Analysis of tests.throwaway (User) on depth 0 completed in 8.75 ms.
Analysis complete: 1 modules in 15.1 ms.

^ here?

MikhailArkhipov commented 4 years ago

It says dependencies: numpy BUT there is no log for numpy. Basic import numpy for me produces very long log like

Analysis of numpy.distutils.command.egg_info (Library) on depth 5 completed for library in 0.5 ms.
Analysis of setuptools.command.install (Library) on depth 6 completed for library in 2.17 ms.
Analysis of numpy.distutils.command.install (Library) on depth 5 completed for library in 2.24 ms.
Analysis of setuptools.command.develop (Library) on depth 6 completed for library in 4.75 ms.
Analysis of numpy.distutils.command.develop (Library) on depth 5 completed for library in 0.39 ms.
Analysis of modules loop on depth 1 in 1814.87 ms:
    numpy(Library)
    numpy.core(Library)
    numpy.lib(Library)
    numpy.linalg(Library)
    numpy.fft(Library)
    numpy.polynomial(Library)
    numpy.random(Library)
    numpy.ctypeslib(Library)
    numpy.ma(Library)
    numpy.matrixlib(Library)
    numpy.testing(Library)
    numpy._pytesttester(Library)
    numpy.linalg.linalg(Library)
    numpy.lib.type_check(Library)
    numpy.lib.index_tricks(Library)
    numpy.lib.function_base(Library)
...
rsokl commented 4 years ago

Do you also get auto-complete suggestions for numpy? Perhaps this is indicative of the issue I am experiencing.

rsokl commented 4 years ago

For example, my vscode does not "see" numpy.testing, which is listed in your log

jakebailey commented 4 years ago

Your output lists a slew of extra paths. Is there a file named "numpy.py" or similar in any of those paths, such that the module is resolving to the wrong location?

Can you verify that you see numpy in /home/user/anaconda3/envs/just_numpy/lib/python3.7/site-packages?

rsokl commented 4 years ago

It is in site-package

$ ls ~/anaconda3/envs/just_numpy/lib/python3.7/site-packages/ | grep numpy
numpy
numpy-1.18.1-py3.7.egg-info

Your output lists a slew of extra paths. Is there a file named "numpy.py" or similar in any of those paths, such that the module is resolving to the wrong location?

Actually I realized that the trace log included me transitioning between conda environments. Here is the log once I activated just_numpy . There are no additional paths.

[Info  - 1:21:51 PM] Analysis caching mode: None.
[Info  - 1:21:53 PM] Analysis cache path: /home/user/.cache/Microsoft/Python Language Server
[Info  - 1:21:53 PM] Microsoft Python Language Server version 0.5.45.0
[Info  - 1:21:53 PM] Workspace root: /home/user/PolloPatches
[Info  - 1:21:53 PM] GetCurrentSearchPaths /home/user/anaconda3/envs/just_numpy/bin/python 
[Info  - 1:21:53 PM] Interpreter search paths:
[Info  - 1:21:53 PM]     /home/user/anaconda3/envs/just_numpy/lib/python3.7
[Info  - 1:21:53 PM]     /home/user/anaconda3/envs/just_numpy/lib/python3.7/lib-dynload
[Info  - 1:21:53 PM]     /home/user/anaconda3/envs/just_numpy/lib/python3.7/site-packages
[Info  - 1:21:53 PM] User search paths:
[Info  - 1:21:54 PM] Initializing for /home/user/anaconda3/envs/just_numpy/bin/python
[Info  - 1:21:54 PM] Analysis caching mode: None.
[Info  - 1:22:09 PM] Analysis caching mode: None.
Code Action in file:///home/user/PolloPatches/pollo_patches/utils/rotate.py at (18, 16) - (18, 16)
Code Action in file:///home/user/PolloPatches/pollo_patches/utils/rotate.py at (18, 16) - (18, 16)
Code Action in file:///home/user/PolloPatches/tests/throwaway.py at (0, 0) - (0, 0)
Code Action in file:///home/user/PolloPatches/tests/throwaway.py at (2, 5) - (2, 5)
Analysis of tests.throwaway (User) queued. Dependencies: numpy
Analysis version 1384 of 1 entries has started.
Analysis of tests.throwaway (User) on depth 0 completed in 8.75 ms.
Analysis complete: 1 modules in 15.1 ms.
Analysis version 1384 of 1 entries has been completed in 9.47 ms.
Code Action in file:///home/user/PolloPatches/tests/throwaway.py at (2, 2) - (2, 2)
Code Action in file:///home/user/PolloPatches/tests/throwaway.py at (2, 2) - (2, 2)
Analysis of tests.throwaway (User) queued. Dependencies: numpy
Analysis version 1385 of 1 entries has started.
Analysis of tests.throwaway (User) on depth 0 completed in 2.23 ms.
Analysis complete: 1 modules in 8.3 ms.
Analysis version 1385 of 1 entries has been completed in 3.3 ms.
Completions in file:///home/user/PolloPatches/tests/throwaway.py at (2, 3)
Analysis of tests.throwaway (User) queued. Dependencies: numpy
Analysis version 1386 of 1 entries has started.
Analysis of tests.throwaway (User) on depth 0 completed in 0.7 ms.
Analysis complete: 1 modules in 2.15 ms.
Analysis version 1386 of 1 entries has been completed in 0.85 ms.
IntelliCode identified 5 likely completion items.
Code Action in file:///home/user/PolloPatches/tests/throwaway.py at (2, 4) - (2, 4)
Analysis of tests.throwaway (User) queued. Dependencies: numpy
Analysis version 1387 of 1 entries has started.
Analysis of tests.throwaway (User) on depth 0 completed in 2.73 ms.
Analysis complete: 1 modules in 7.01 ms.
Analysis version 1387 of 1 entries has been completed in 3.41 ms.
Code Action in file:///home/user/PolloPatches/tests/throwaway.py at (2, 5) - (2, 5)
Code Action in file:///home/user/PolloPatches/tests/throwaway.py at (2, 5) - (2, 5)
jakebailey commented 4 years ago

Hm, is there a file named "numpy" in the workspace (/home/user/PolloPatches)?

MikhailArkhipov commented 4 years ago

Yes, I do have completions image

MikhailArkhipov commented 4 years ago
rsokl commented 4 years ago

Is there a clean way to restart the language server in a workspace without having to kill VSCode?

jakebailey commented 4 years ago

One method is to kill the LS process; the VS Code client will restart the process up to 5 times.

Another is to switch interpreter and go back again, which (currently) forces a restart.

Adding a specific command to the extension to force a restart is an ongoing thing that'll have to be made there.

rsokl commented 4 years ago

If you create completely new, empty project and import numpy, does it work?

It does! I just created an empty folder / workspace and created dummy_file.py

Here is the (very long) trace log

[Info  - 4:55:16 PM] Analysis cache path: /home/user/.cache/Microsoft/Python Language Server
[Info  - 4:55:16 PM] Microsoft Python Language Server version 0.5.45.0
[Info  - 4:55:16 PM] Workspace root: /home/user/dummy_workspace
[Info  - 4:55:16 PM] GetCurrentSearchPaths /home/user/anaconda3/envs/just_numpy/bin/python 
[Info  - 4:55:16 PM] Interpreter search paths:
[Info  - 4:55:16 PM]     /home/user/anaconda3/envs/just_numpy/lib/python3.7
[Info  - 4:55:16 PM]     /home/user/anaconda3/envs/just_numpy/lib/python3.7/lib-dynload
[Info  - 4:55:16 PM]     /home/user/anaconda3/envs/just_numpy/lib/python3.7/site-packages
[Info  - 4:55:16 PM] User search paths:
[Info  - 4:55:16 PM] Initializing for /home/user/anaconda3/envs/just_numpy/bin/python
[Info  - 4:55:16 PM] Analysis caching mode: None.
Opening document file:///home/user/dummy_workspace/dummy_file.py
Analysis of dummy_file (User) queued. Dependencies: numpy
Code Action in file:///home/user/dummy_workspace/dummy_file.py at (1, 6) - (1, 6)
Import:  numpy /home/user/anaconda3/envs/just_numpy/lib/python3.7/site-packages/numpy/__init__.py 
Analysis version 1 of 1 entries has started.
Analysis of numpy (Stub) queued. Dependencies: numpy.core._multiarray_umath (stub)
Analysis of numpy.core._multiarray_umath (Stub) queued. Dependencies: sys (stub)
Analysis of sys (Stub) queued. Dependencies: types (stub), importlib.abc (stub)
Analysis of types (Stub) queued. Dependencies: sys (stub), _importlib_modulespec (stub)
Analysis of _importlib_modulespec (Stub) queued. Dependencies: abc (stub), sys (stub)
Analysis of importlib.abc (Stub) queued. Dependencies: abc (stub), os (stub), sys (stub), types (stub), _importlib_modulespec (stub)
Analysis of dummy_file (User) on depth 0 completed in 43.26 ms.
Analysis of abc (Stub) queued. Dependencies: 
Analysis version 1 of 1 entries has been completed in 60.65 ms.
Analysis of numpy (Library) queued. Dependencies: numpy (stub), __future__, sys, warnings, numpy._globals, numpy.__config__, numpy.version, numpy._distributor_init, numpy.core, numpy.compat, numpy.lib, numpy.linalg, numpy.fft, numpy.polynomial, numpy.random, numpy.ctypeslib, numpy.ma, numpy.matrixlib, numpy.testing, numpy._pytesttester, mkl
Analysis version 15 of 2 entries has started.
Import:  __future__ /home/user/anaconda3/envs/just_numpy/lib/python3.7/__future__.py 
Analysis of __future__ (Stub) queued. Dependencies: sys (stub)
Create built-in compiled (scraped) module:  sys /home/user/anaconda3/envs/just_numpy/bin/python 
Import:  warnings /home/user/anaconda3/envs/just_numpy/lib/python3.7/warnings.py 
Import:  numpy._globals /home/user/anaconda3/envs/just_numpy/lib/python3.7/site-packages/numpy/_globals.py 
Analysis of warnings (Stub) queued. Dependencies: types (stub)
Import:  numpy.__config__ /home/user/anaconda3/envs/just_numpy/lib/python3.7/site-packages/numpy/__config__.py 
Import:  numpy.version /home/user/anaconda3/envs/just_numpy/lib/python3.7/site-packages/numpy/version.py 
Analysis of numpy._globals (Library) queued. Dependencies: __future__
Analysis of __future__ (Library) queued. Dependencies: __future__ (stub)
Analysis of numpy.version (Library) queued. Dependencies: 
Import:  numpy._distributor_init /home/user/anaconda3/envs/just_numpy/lib/python3.7/site-packages/numpy/_distributor_init.py 
Import:  numpy.core /home/user/anaconda3/envs/just_numpy/lib/python3.7/site-packages/numpy/core/__init__.py 
Analysis of numpy._distributor_init (Library) queued. Dependencies: mkl, warnings
Analysis of os (Stub) queued. Dependencies: io (stub), sys (stub), posix (stub), os.path (stub)
Import:  numpy.compat /home/user/anaconda3/envs/just_numpy/lib/python3.7/site-packages/numpy/compat/__init__.py 
Import:  numpy.lib /home/user/anaconda3/envs/just_numpy/lib/python3.7/site-packages/numpy/lib/__init__.py 
Analysis of numpy.compat (Library) queued. Dependencies: __future__, numpy.compat._inspect, numpy.compat.py3k
Import:  numpy.linalg /home/user/anaconda3/envs/just_numpy/lib/python3.7/site-packages/numpy/linalg/__init__.py 
Import:  numpy.fft /home/user/anaconda3/envs/just_numpy/lib/python3.7/site-packages/numpy
(and so on...)
rsokl commented 4 years ago

Hm, is there a file named "numpy" in the workspace

No, there is no such file in the work space

jakebailey commented 4 years ago

I'm not entirely certain how to debug this without the actual workspace. numpy aliasing is the main thing to check, and switching to a fresh repo but with the same environment would hint that there's something odd in the workspace.

MikhailArkhipov commented 4 years ago

As @jakebailey said, something in the workspace prevents resolution of import to real numpy. What happens if you hover over numpy or try goto definition on numpy in the import?

rsokl commented 4 years ago

What happens if you hover over numpy or try goto definition on numpy in the import?

Hovering over numpy renders the appropriate docstring for numpy. And "go-to-definition" takes me to /home/user/anaconda3/envs/just_numpy/lib/python3.7/site-packages/numpy/__init__.py

image

rsokl commented 4 years ago

I'm stepping through the work space carefully, and do not see any files named numpy.py (I would certainly never name something this...)

jakebailey commented 4 years ago

A folder named numpy may also do it, but I'm assuming you're also checking for that. Maybe the output of tree to get the gist of how your code is laid out would help, but I'm not sure what you're comfortable sharing.

MikhailArkhipov commented 4 years ago

So the numpy is real since its doc string is correct. So typing numpy. right after that import yields nothing?

rsokl commented 4 years ago

First of all, thank you both for your kind help and generous patience! I really appreciate it.

So typing numpy. right after that import yields nothing?

It yields nothing. Only after typing a single letter does it try to use the local namespace image

Maybe the output of tree to get the gist of how your code is laid out would help

I excluded the docs/ directory for readability but did check that it does not contain any files called numpy


PolloPatches/
├── data
│   ├── mean_var.npz
│   ├── #README.md#
│   └── README.md
├── descriptor_quality
│   ├── descriptors.npz
│   ├── EO_Descriptor_Quality.md
│   └── temp.pt
├── keypoints
├── models
│   └── checkpoint_00100000.pt
├── new_models
│   └── checkpoint_00100000.pt
├── pollo_patches
│   ├── descriptors
│   │   ├── analysis.py
│   │   ├── __init__.py
│   │   └── __pycache__
│   │       ├── analysis.cpython-37.pyc
│   │       ├── calc_keypoints.cpython-37.pyc
│   │       └── __init__.cpython-37.pyc
│   ├── experiment.py
│   ├── __init__.py
│   ├── keypoints
│   │   ├── __init__.py
│   │   ├── __pycache__
│   │   │   ├── __init__.cpython-37.pyc
│   │   │   ├── sift.cpython-37.pyc
│   │   │   └── utils.cpython-37.pyc
│   │   ├── sift.py
│   │   └── utils.py
│   ├── performance_metrics.py
│   ├── __pycache__
│   │   ├── experiment.cpython-37.pyc
│   │   ├── __init__.cpython-37.pyc
│   │   ├── performance_metrics.cpython-37.pyc
│   │   ├── pytorch.cpython-37.pyc
│   │   ├── transforms.cpython-37.pyc
│   │   ├── typing.cpython-37.pyc
│   │   └── utils.cpython-37.pyc
│   ├── pytorch.py
│   ├── transforms
│   │   ├── __init__.py
│   │   ├── __pycache__
│   │   │   ├── __init__.cpython-37.pyc
│   │   │   └── _zoom.cpython-37.pyc
│   │   └── _zoom.py
│   ├── typing.py
│   ├── utils
│   │   ├── __init__.py
│   │   ├── patches.py
│   │   ├── __pycache__
│   │   │   ├── __init__.cpython-37.pyc
│   │   │   ├── patches.cpython-37.pyc
│   │   │   └── rotate.cpython-37.pyc
│   │   └── rotate.py
│   ├── utils.py
│   └── xarray
│       ├── csv.py
│       ├── datastructures.py
│       ├── __init__.py
│       ├── io.py
│       ├── __pycache__
│       │   ├── csv.cpython-37.pyc
│       │   ├── datastructures.cpython-37.pyc
│       │   ├── __init__.cpython-37.pyc
│       │   ├── io.cpython-37.pyc
│       │   └── utils.cpython-37.pyc
│       └── utils.py
├── pollo_patches.egg-info
│   ├── dependency_links.txt
│   ├── PKG-INFO
│   ├── requires.txt
│   ├── SOURCES.txt
│   └── top_level.txt
├── README.md
├── setup.py
├── tests
│   ├── conftest.py
│   ├── custom_strategies.py
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── conftest.cpython-37-pytest-5.4.1.pyc
│   │   ├── conftest.cpython-37-PYTEST.pyc
│   │   ├── custom_strategies.cpython-37.pyc
│   │   ├── __init__.cpython-37.pyc
│   │   ├── test_custom_strategies.cpython-37-pytest-5.4.1.pyc
│   │   ├── test_custom_strategies.cpython-37-PYTEST.pyc
│   │   ├── test_descriptor_utils.cpython-37-pytest-5.4.1.pyc
│   │   ├── test_descriptor_utils.cpython-37-PYTEST.pyc
│   │   ├── test_performance_metrics.cpython-37-pytest-5.4.1.pyc
│   │   ├── test_performance_metrics.cpython-37-PYTEST.pyc
│   │   ├── test_pytorch.cpython-37-pytest-5.4.1.pyc
│   │   ├── test_pytorch.cpython-37-PYTEST.pyc
│   │   ├── test_rotation.cpython-37-pytest-5.4.1.pyc
│   │   ├── test_sift_keypoints.cpython-37-pytest-5.4.1.pyc
│   │   ├── test_sift_keypoints.cpython-37-PYTEST.pyc
│   │   ├── test_transforms.cpython-37-pytest-5.4.1.pyc
│   │   ├── test_transforms.cpython-37-PYTEST.pyc
│   │   ├── test_typing.cpython-37-pytest-5.4.1.pyc
│   │   ├── test_typing.cpython-37-PYTEST.pyc
│   │   ├── test_utils.cpython-37-pytest-5.4.1.pyc
│   │   ├── test_utils.cpython-37-PYTEST.pyc
│   │   ├── test_zoom.cpython-37-pytest-5.4.1.pyc
│   │   └── test_zoom.cpython-37-PYTEST.pyc
│   ├── test_custom_strategies.py
│   ├── test_descriptors
│   │   ├── __init__.py
│   │   ├── __pycache__
│   │   │   ├── __init__.cpython-37.pyc
│   │   │   └── test_analysis.cpython-37-pytest-5.4.1.pyc
│   │   └── test_analysis.py
│   ├── test_descriptor_utils.py
│   ├── test_performance_metrics.py
│   ├── test_pytorch.py
│   ├── test_rotation.py
│   ├── test_sift_keypoints.py
│   ├── test_transforms.py
│   ├── test_typing.py
│   ├── test_utils.py
│   ├── test_xarray
│   │   ├── __init__.py
│   │   ├── __pycache__
│   │   │   ├── __init__.cpython-37.pyc
│   │   │   ├── test_csv.cpython-37-pytest-5.4.1.pyc
│   │   │   ├── test_csv.cpython-37-PYTEST.pyc
│   │   │   ├── test_io.cpython-37-pytest-5.4.1.pyc
│   │   │   └── test_io.cpython-37-PYTEST.pyc
│   │   ├── test_csv.py
│   │   └── test_io.py
│   └── test_zoom.py
├── training_data
│   ├── cut0.npz
│   └── cut1.npz
└── tutorials
    └── running_sift.md
rsokl commented 4 years ago

I tried doing making a fresh clone and creating a new workspace for this project to no avail. Oddly enough other 3rd party libraries, including scipy, seem to work fine

rsokl commented 4 years ago

So.. playing around with this more makes me think that this issue is actually associated with my conda environment. I thought that I had successfully reproduced these issues with a clean conda environment, but now I am finding otherwise.

I'm not sure if this makes any difference, but I am also using the pyright extension, which does analysis as well.

In my clean workspace with my just_numpy conda environment, I can get auto-complete on numpy to work:

With just_numpy conda env

numpy works with conda-env just_numpy

I had also noticed that I couldn't get any intellicode to work with the hypothesis library either. However this also works (after installing via pypi) on my: just_numpy conda environment:

hypothesis works with conda-env just_numpy

just_numpy env file

name: just_numpy
channels:
  - defaults
dependencies:
  - _libgcc_mutex=0.1=main
  - blas=1.0=mkl
  - ca-certificates=2020.1.1=0
  - certifi=2020.4.5.1=py37_0
  - intel-openmp=2020.0=166
  - ld_impl_linux-64=2.33.1=h53a641e_7
  - libedit=3.1.20181209=hc058e9b_0
  - libffi=3.2.1=hd88cf55_4
  - libgcc-ng=9.1.0=hdf63c60_0
  - libgfortran-ng=7.3.0=hdf63c60_0
  - libstdcxx-ng=9.1.0=hdf63c60_0
  - mkl=2020.0=166
  - mkl-service=2.3.0=py37he904b0f_0
  - mkl_fft=1.0.15=py37ha843d7b_0
  - mkl_random=1.1.0=py37hd6b4f25_0
  - ncurses=6.2=he6710b0_0
  - numpy=1.18.1=py37h4f9e942_0
  - numpy-base=1.18.1=py37hde5b4d6_1
  - openssl=1.1.1f=h7b6447c_0
  - pip=20.0.2=py37_1
  - python=3.7.7=hcf32534_0_cpython
  - readline=8.0=h7b6447c_0
  - setuptools=46.1.3=py37_0
  - six=1.14.0=py37_0
  - sqlite=3.31.1=h7b6447c_0
  - tk=8.6.8=hbc83047_0
  - wheel=0.34.2=py37_0
  - xz=5.2.5=h7b6447c_0
  - zlib=1.2.11=h7b6447c_3
  - pip:
    - attrs==19.3.0
    - hypothesis==5.10.3
    - sortedcontainers==2.1.0
prefix: /home/user/anaconda3/envs/just_numpy

With hardnet conda env

numpy does not works with conda-env hardnet

hypothesis does not works with conda-env hardnet

hardnet env file

name: hardnet
channels:
  - pytorch
  - defaults
dependencies:
  - _libgcc_mutex=0.1=main
  - attrs=19.3.0=py_0
  - backcall=0.1.0=py37_0
  - blas=1.0=mkl
  - bleach=3.1.0=py37_0
  - bzip2=1.0.8=h7b6447c_0
  - ca-certificates=2020.1.1=0
  - cairo=1.14.12=h8948797_3
  - certifi=2020.4.5.1=py37_0
  - cffi=1.14.0=py37h2e261b9_0
  - cloudpickle=1.3.0=py_0
  - cudatoolkit=10.1.243=h6bb024c_0
  - cycler=0.10.0=py37_0
  - cytoolz=0.10.1=py37h7b6447c_0
  - dask-core=2.14.0=py_0
  - dbus=1.13.12=h746ee38_0
  - decorator=4.4.2=py_0
  - defusedxml=0.6.0=py_0
  - entrypoints=0.3=py37_0
  - expat=2.2.6=he6710b0_0
  - ffmpeg=4.0=hcdf2ecd_0
  - fontconfig=2.13.0=h9420a91_0
  - freeglut=3.0.0=hf484d3e_5
  - freetype=2.9.1=h8a8886c_1
  - glib=2.63.1=h5a9c865_0
  - gmp=6.1.2=h6c8ec71_1
  - graphite2=1.3.13=h23475e2_0
  - gst-plugins-base=1.14.0=hbbd80ab_1
  - gstreamer=1.14.0=hb453b48_1
  - h5py=2.8.0=py37h989c5e5_3
  - harfbuzz=1.8.8=hffaf4a1_0
  - hdf5=1.10.2=hba1933b_1
  - icu=58.2=h9c2bf20_1
  - imageio=2.8.0=py_0
  - importlib_metadata=1.5.0=py37_0
  - intel-openmp=2019.4=243
  - ipykernel=5.1.4=py37h39e3cac_0
  - ipython=7.5.0=py37h39e3cac_0
  - ipython_genutils=0.2.0=py37_0
  - ipywidgets=7.5.1=py_0
  - jasper=2.0.14=h07fcdf6_1
  - jedi=0.16.0=py37_1
  - jinja2=2.11.1=py_0
  - joblib=0.14.1=py_0
  - jpeg=9b=h024ee3a_2
  - jsonschema=3.2.0=py37_0
  - jupyter=1.0.0=py37_7
  - jupyter_client=6.1.2=py_0
  - jupyter_console=6.1.0=py_0
  - jupyter_core=4.6.3=py37_0
  - kiwisolver=1.1.0=py37he6710b0_0
  - libedit=3.1.20181209=hc058e9b_0
  - libffi=3.2.1=hd88cf55_4
  - libgcc-ng=9.1.0=hdf63c60_0
  - libgfortran-ng=7.3.0=hdf63c60_0
  - libglu=9.0.0=hf484d3e_1
  - libopencv=3.4.2=hb342d67_1
  - libopus=1.3=h7b6447c_0
  - libpng=1.6.37=hbc83047_0
  - libsodium=1.0.16=h1bed415_0
  - libstdcxx-ng=9.1.0=hdf63c60_0
  - libtiff=4.1.0=h2733197_0
  - libuuid=1.0.3=h1bed415_2
  - libvpx=1.7.0=h439df22_0
  - libxcb=1.13=h1bed415_1
  - libxml2=2.9.9=hea5a465_1
  - llvmlite=0.30.0=py37hd408876_0
  - markupsafe=1.1.1=py37h7b6447c_0
  - matplotlib=3.0.3=py37h5429711_0
  - mistune=0.8.4=py37h7b6447c_0
  - mkl=2019.4=243
  - mkl-service=2.3.0=py37he904b0f_0
  - mkl_fft=1.0.15=py37ha843d7b_0
  - mkl_random=1.1.0=py37hd6b4f25_0
  - nbconvert=5.6.1=py37_0
  - nbformat=5.0.4=py_0
  - ncurses=6.2=he6710b0_0
  - networkx=2.4=py_0
  - ninja=1.9.0=py37hfd86e86_0
  - notebook=5.7.8=py37_0
  - numba=0.46.0=py37h962f231_0
  - numpy=1.16.3=py37h7e9f1db_0
  - numpy-base=1.16.3=py37hde5b4d6_0
  - olefile=0.46=py37_0
  - opencv=3.4.2=py37h6fd60c2_1
  - openssl=1.1.1g=h7b6447c_0
  - pandas=1.0.3=py37h0573a6f_0
  - pandoc=2.2.3.2=0
  - pandocfilters=1.4.2=py37_1
  - parso=0.6.2=py_0
  - pcre=8.43=he6710b0_0
  - pexpect=4.8.0=py37_0
  - pickleshare=0.7.5=py37_0
  - pillow=7.0.0=py37hb39fc2d_0
  - pip=20.0.2=py37_1
  - pixman=0.38.0=h7b6447c_0
  - prometheus_client=0.7.1=py_0
  - prompt_toolkit=2.0.9=py37_0
  - ptyprocess=0.6.0=py37_0
  - py-opencv=3.4.2=py37hb342d67_1
  - pycparser=2.20=py_0
  - pygments=2.6.1=py_0
  - pyparsing=2.4.6=py_0
  - pyqt=5.9.2=py37h05f1152_2
  - pyrsistent=0.16.0=py37h7b6447c_0
  - python=3.7.3=h0371630_0
  - python-dateutil=2.8.1=py_0
  - pytorch=1.5.0=py3.7_cuda10.1.243_cudnn7.6.3_0
  - pytz=2019.3=py_0
  - pywavelets=1.1.1=py37h7b6447c_0
  - pyzmq=18.1.1=py37he6710b0_0
  - qt=5.9.7=h5867ecd_1
  - qtconsole=4.7.2=py_0
  - qtpy=1.9.0=py_0
  - readline=7.0=h7b6447c_5
  - scikit-image=0.16.2=py37h0573a6f_0
  - scikit-learn=0.22.1=py37hd81dba3_0
  - scipy=1.4.1=py37h0b6359f_0
  - send2trash=1.5.0=py37_0
  - setuptools=46.1.3=py37_0
  - sip=4.19.8=py37hf484d3e_0
  - six=1.14.0=py37_0
  - sqlite=3.31.1=h7b6447c_0
  - tbb=2020.0=hfd86e86_0
  - terminado=0.8.3=py37_0
  - testpath=0.4.4=py_0
  - tk=8.6.8=hbc83047_0
  - toolz=0.10.0=py_0
  - torchvision=0.6.0=py37_cu101
  - tornado=6.0.4=py37h7b6447c_1
  - traitlets=4.3.3=py37_0
  - webencodings=0.5.1=py37_1
  - wheel=0.34.2=py37_0
  - widgetsnbextension=3.5.1=py37_0
  - xarray=0.15.0=py_0
  - xz=5.2.4=h14c3975_4
  - zeromq=4.3.1=he6710b0_3
  - zlib=1.2.11=h7b6447c_3
  - zstd=1.3.7=h0b5b093_0
  - pip:
    - alabaster==0.7.12
    - appdirs==1.4.3
    - astroid==2.2.5
    - atomicwrites==1.3.0
    - babel==2.8.0
    - bandit==1.6.2
    - black==19.10b0
    - chardet==3.0.4
    - click==7.0
    - colour-demosaicing==0.1.5
    - colour-science==0.3.15
    - coverage==4.5.3
    - custom-inherit==2.2.0
    - docutils==0.16
    - filelock==3.0.12
    - gitdb2==2.0.5
    - gitpython==3.0.2
    - hypothesis==4.33.0
    - hypothesis-networkx==0.2.0
    - idna==2.9
    - imagesize==1.2.0
    - importlib-metadata==0.19
    - isort==4.3.21
    - jupyterthemes==0.20.0
    - jupytext==1.3.2
    - lazy-object-proxy==1.4.2
    - lesscpy==0.13.0
    - mccabe==0.6.1
    - more-itertools==8.2.0
    - mygrad==1.5.0
    - nbsphinx==0.5.1
    - noggin==0.10.1
    - numpydoc==0.9.2
    - packaging==19.1
    - pathspec==0.7.0
    - pbr==5.2.0
    - pluggy==0.12.0
    - ply==3.11
    - py==1.8.0
    - pylint==2.3.1
    - pytest==5.4.1
    - pytest-cov==2.7.1
    - pyyaml==5.1.2
    - regex==2020.2.20
    - requests==2.23.0
    - rstcheck==3.3.1
    - smmap2==2.0.5
    - snowballstemmer==2.0.0
    - sphinx==2.4.4
    - sphinx-rtd-theme==0.4.3
    - sphinxcontrib-applehelp==1.0.2
    - sphinxcontrib-devhelp==1.0.2
    - sphinxcontrib-htmlhelp==1.0.3
    - sphinxcontrib-jsmath==1.0.1
    - sphinxcontrib-qthelp==1.0.3
    - sphinxcontrib-serializinghtml==1.1.4
    - sphinxcontrib-websupport==1.2.1
    - stevedore==1.31.0
    - toml==0.10.0
    - tox==3.13.2
    - tox-conda==0.2.0
    - tqdm==4.45.0
    - typed-ast==1.4.0
    - typing-extensions==3.7.4.1
    - urllib3==1.25.8
    - virtualenv==16.7.3
    - wcwidth==0.1.7
    - wrapt==1.11.2
    - zipp==0.5.2
prefix: /home/user/anaconda3/envs/hardnet
againxx commented 4 years ago

Having the same issue! autocompletion works fine with a clean conda env which only has numpy, but after I installed tensorflow-gpu=1.15, the completion of numpy was inconsistent. Some basic functions like array(), didn't show up every time. np_array

MikhailArkhipov commented 4 years ago

Most probably there is a problem analyzing modules with deep circular dependencies.

quatsch83 commented 4 years ago

I am also having a similar problem, except that I cannot see any of the functions in numpy.random:

image

Here is my entire trace log attached:

py_lang_serv.log

sachit-menon commented 4 years ago

Is there any update on this? I have the same issue when installing numpy in a fresh environment.

jakebailey commented 4 years ago

Have you tried on 0.5.51 (which I believe is in our beta channel)?

"python.analysis.downloadChannel": "beta"
sachit-menon commented 4 years ago

Hi, using 0.5.51 I seem to get the behavior described in #2018 and by @quatsch83 above. The log is

[Info  - 12:30:25 PM] Analysis cache path: /Users/sachit/Library/Caches/Microsoft/Python Language Server
[Info  - 12:30:25 PM] Microsoft Python Language Server version 0.5.51.0
[Info  - 12:30:25 PM] Workspace root: 
[Info  - 12:30:26 PM] GetCurrentSearchPaths /Users/sachit/opt/miniconda3/envs/vstest/bin/python 
[Info  - 12:30:26 PM] Interpreter search paths:
[Info  - 12:30:26 PM]     /Users/sachit/opt/miniconda3/envs/vstest/lib/python3.8
[Info  - 12:30:26 PM]     /Users/sachit/opt/miniconda3/envs/vstest/lib/python3.8/lib-dynload
[Info  - 12:30:26 PM]     /Users/sachit/opt/miniconda3/envs/vstest/lib/python3.8/site-packages
[Info  - 12:30:26 PM] User search paths:
[Info  - 12:30:26 PM] Initializing for /Users/sachit/opt/miniconda3/envs/vstest/bin/python

A short code block to reproduce:

import numpy as np

np.linspace()
np.arange()

np.linspace autocompletes fine and provides documentation when prompted. np.arange does not, nor does anything in np.random. This is in a fresh environment of Python 3.8.3 64-bit with conda install numpy applied, resulting in

# packages in environment at /Users/sachit/opt/miniconda3/envs/vstest:
#
# Name                    Version                   Build  Channel
blas                      1.0                         mkl  
ca-certificates           2020.1.1                      0  
certifi                   2020.6.20                py38_0  
intel-openmp              2019.4                      233  
libcxx                    10.0.0                        1  
libedit                   3.1.20191231         haf1e3a3_0  
libffi                    3.3                  h0a44026_1  
libgfortran               3.0.1                h93005f0_2  
mkl                       2019.4                      233  
mkl-service               2.3.0            py38hfbe908c_0  
mkl_fft                   1.1.0            py38hc64f4ea_0  
mkl_random                1.1.1            py38h959d312_0  
ncurses                   6.2                  h0a44026_1  
numpy                     1.18.5           py38h1da2735_0  
numpy-base                1.18.5           py38h3304bdc_0  
openssl                   1.1.1g               h1de35cc_0  
pip                       20.1.1                   py38_1  
python                    3.8.3                h26836e1_1  
readline                  8.0                  h1de35cc_0  
setuptools                47.3.1                   py38_0  
six                       1.15.0                     py_0  
sqlite                    3.32.3               hffcf06c_0  
tk                        8.6.10               hb0a8c7a_0  
wheel                     0.34.2                   py38_0  
xz                        5.2.5                h1de35cc_0  
zlib                      1.2.11               h1de35cc_3

as the environment.

Happy to provide any other information you need to help resolve this.