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

Pylance not working in vs code interactive window #1586

Closed
dataagile-ema opened this issue Jul 22, 2021 Discussed in #1585 · 13 comments
Closed

Pylance not working in vs code interactive window #1586

dataagile-ema opened this issue Jul 22, 2021 Discussed in #1585 · 13 comments
Assignees
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@dataagile-ema
Copy link

Discussed in #1585

Originally posted by dataagile-ema July 22, 2021
Hi!

Whenever pylance detects a problem when i am in the interactive window in vs code, it just stops working. It no longer gives autocomplete (to make things worse, pylance detects problem even when there is no problem). I hope the attached image shows the problem.
I would greatly appreciate help on ths, it i really irritating. Pylance autocomplete really speads up development.

vs code pylance

@judej
Copy link
Contributor

judej commented Jul 22, 2021

Would you please provide logs and repro steps as described in the troubleshooting guide, please?

@judej judej added the waiting for user response Requires more information from user label Jul 22, 2021
@github-actions github-actions bot removed the triage label Jul 22, 2021
@dataagile-ema
Copy link
Author

pylance version v2021.7.5
g_environment_yml.txt
'Python 3.9.6 64-bit

The code is pretty much what you see in the image I attached, but the code could be anything, e.g:
import pandas as pd
import altair as alt
df = pd. does give any suggestions for methods in pandas module. Sometimes autocomplete works for a short while, then it stops.
I set VS Code tol loggning Trace, but the the debud console does not output anything.
Hope that helps.

@jakebailey
Copy link
Member

The logs we are interested in are printed in the Python Language Server output window, here:

image

@dataagile-ema
Copy link
Author

dataagile-ema commented Jul 23, 2021

langserverlog.txt
here is the log
Unfurtuantly, i tried some diffrent things, so it not a clean logfile. The problem is intermittent, some times pylance works when i runt a interactive window, but never for long. And the error can also express in a few diffrent forms.
Hope the info helps, please tell me if you need more info.

@jakebailey
Copy link
Member

jakebailey commented Jul 23, 2021

Things aren't working because the LS is crashing.

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
    at validateString (internal/validators.js:124:11)
    at Object.basename (path.js:671:5)
    at Object.getFileName (c:\Users\nikla.DESKTOP-78VQUGU\.vscode\extensions\ms-python.vscode-pylance-2021.7.5\dist\pyright-internal\src\common\pathUtils.ts:535:17)
    at listener (c:\Users\nikla.DESKTOP-78VQUGU\.vscode\extensions\ms-python.vscode-pylance-2021.7.5\dist\pyright-internal\src\analyzer\service.ts:1282:38)
    at FSWatcher.<anonymous> (c:\Users\nikla.DESKTOP-78VQUGU\.vscode\extensions\ms-python.vscode-pylance-2021.7.5\dist\pyright-internal\src\common\realFileSystem.ts:387:25)
    at FSWatcher.emit (events.js:315:20)
    at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:186:12)
[Info  - 20:14:54] Connection to server got closed. Server will restart.
[Info  - 20:14:55] Pylance language server 2021.7.5 (pyright 06d75c6c) starting

The logs show that one of your paths is apparently empty:

Search paths for 
  c:\Users\nikla.DESKTOP-78VQUGU\.vscode\extensions\ms-python.vscode-pylance-2021.7.5\dist\typeshed-fallback\stdlib
  
  typings
  c:\Users\nikla.DESKTOP-78VQUGU\.vscode\extensions\ms-python.vscode-pylance-2021.7.5\dist\typeshed-fallback\stubs\...
  c:\Users\nikla.DESKTOP-78VQUGU\.vscode\extensions\ms-python.vscode-pylance-2021.7.5\dist\bundled\stubs
  c:\Users\nikla.DESKTOP-78VQUGU\Anaconda3\DLLs
  c:\Users\nikla.DESKTOP-78VQUGU\Anaconda3\Lib
  c:\Users\nikla.DESKTOP-78VQUGU\Anaconda3
  c:\Users\nikla.DESKTOP-78VQUGU\Anaconda3\Lib\site-packages
  c:\Users\nikla.DESKTOP-78VQUGU\Anaconda3\Lib\site-packages\win32
  c:\Users\nikla.DESKTOP-78VQUGU\Anaconda3\Lib\site-packages\win32\lib
  c:\Users\nikla.DESKTOP-78VQUGU\Anaconda3\Lib\site-packages\pythonwin

Potentially null. I think this is because you are not opening a folder (open file mode has a few known issues), but we shouldn't be crashing or adding an empty workspace path as a search path (or then try to watch it).

@jakebailey jakebailey added bug Something isn't working needs investigation Could be an issue - needs investigation and removed waiting for user response Requires more information from user labels Jul 23, 2021
@dataagile-ema
Copy link
Author

Things aren't working because the LS is crashing.

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
    at validateString (internal/validators.js:124:11)
    at Object.basename (path.js:671:5)
    at Object.getFileName (c:\Users\nikla.DESKTOP-78VQUGU\.vscode\extensions\ms-python.vscode-pylance-2021.7.5\dist\pyright-internal\src\common\pathUtils.ts:535:17)
    at listener (c:\Users\nikla.DESKTOP-78VQUGU\.vscode\extensions\ms-python.vscode-pylance-2021.7.5\dist\pyright-internal\src\analyzer\service.ts:1282:38)
    at FSWatcher.<anonymous> (c:\Users\nikla.DESKTOP-78VQUGU\.vscode\extensions\ms-python.vscode-pylance-2021.7.5\dist\pyright-internal\src\common\realFileSystem.ts:387:25)
    at FSWatcher.emit (events.js:315:20)
    at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:186:12)
[Info  - 20:14:54] Connection to server got closed. Server will restart.
[Info  - 20:14:55] Pylance language server 2021.7.5 (pyright 06d75c6c) starting

The logs show that one of your paths is apparently empty:

Search paths for 
  c:\Users\nikla.DESKTOP-78VQUGU\.vscode\extensions\ms-python.vscode-pylance-2021.7.5\dist\typeshed-fallback\stdlib
  
  typings
  c:\Users\nikla.DESKTOP-78VQUGU\.vscode\extensions\ms-python.vscode-pylance-2021.7.5\dist\typeshed-fallback\stubs\...
  c:\Users\nikla.DESKTOP-78VQUGU\.vscode\extensions\ms-python.vscode-pylance-2021.7.5\dist\bundled\stubs
  c:\Users\nikla.DESKTOP-78VQUGU\Anaconda3\DLLs
  c:\Users\nikla.DESKTOP-78VQUGU\Anaconda3\Lib
  c:\Users\nikla.DESKTOP-78VQUGU\Anaconda3
  c:\Users\nikla.DESKTOP-78VQUGU\Anaconda3\Lib\site-packages
  c:\Users\nikla.DESKTOP-78VQUGU\Anaconda3\Lib\site-packages\win32
  c:\Users\nikla.DESKTOP-78VQUGU\Anaconda3\Lib\site-packages\win32\lib
  c:\Users\nikla.DESKTOP-78VQUGU\Anaconda3\Lib\site-packages\pythonwin

Potentially null. I think this is because you are not opening a folder (open file mode has a few known issues), but we shouldn't be crashing or adding an empty workspace path as a search path (or then try to watch it).

I could do another log, when actually opening an repo and then going into interactive window. I am pretty sure that was what I did when I posted the problem yesterday (see original post and image). Would it be of help to have that log too?

@jakebailey
Copy link
Member

I think we have enough info.

You should be able to work around this by using Open Folder, rather than just opening up your notebook file. Can you confirm that it works when you do that?

@dataagile-ema
Copy link
Author

First the workaround works, i get the autocomplete as expeted, and then i stops, see image

image_vscode

langserverlog_part2.txt

@jakebailey
Copy link
Member

The other thing to confirm is that the interpreter that you've selected is the same one that is running the kernel. Pylance uses the interpreter that the Python extension chooses, but Jupyter uses a separate selection that isn't always synchronized.

Try creating a plain python file in that folder and write the same code, and see if alt works.

@dataagile-ema
Copy link
Author

dataagile-ema commented Jul 23, 2021

When a create a plain python file, everything works, a get autcomplete for alt. And that is my experience, I have this problem when running interactive window.
I also tried creating a jupyter notebook and autocomplete works fine with the same code as above. It only stops working when I rename the notebook file. But if I don’t rename the notebook, autocomplete works consistently.

@psobolewskiPhD
Copy link

Same issues here in Version: 1.59.0-insider (apple silicon native)
Really annoying!

@jakebailey jakebailey added in backlog fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed needs investigation Could be an issue - needs investigation labels Sep 2, 2021
@jakebailey
Copy link
Member

The next version should fix various errors / bad behaviors caused by open-file mode; we weren't being too careful about handling an unrooted execution environment in a number of places (but now handle it explicitly).

@jakebailey
Copy link
Member

This issue has been fixed in version 2021.9.2, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202192-16-september-2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

4 participants