positron icon indicating copy to clipboard operation
positron copied to clipboard

Python autocomplete doesnt work on notebook

Open mertgoksel opened this issue 1 year ago • 17 comments

Type: Bug

get into a notebook

case 1: type import no package can be found

case 2: type "pri" "print" is not shown in suggestions.

VS Code version: Positron 1.90.0 (9f24124be55ef409fb6b6c75ee80232f298cd56b, 2024-07-12T03:18:15.685Z) OS version: Windows_NT x64 10.0.22621 Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i5-9300H CPU @ 2.40GHz (8 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 15.86GB (6.41GB free)
Process Argv
Screen Reader no
VM 0%
Extensions: none (1 theme extensions excluded)

mertgoksel avatar Jul 13 '24 12:07 mertgoksel

image image

I can't reproduce on a mac. Can anyone on Windows reproduce?

nstrayer avatar Jul 15 '24 14:07 nstrayer

I can't reproduce this issue in Positron on Windows with a basic Notebook using Python 3.11.6 as the kernel.

It is possible the language runtime stopped somehow and thus a kernel and LSP are not available to the notebook? To see if you have a kernel, you could declare a variable and assign it a value. After executing the cell, if the variable shows up in the Variables pane for that notebook's runtime, at least the kernel is running.

Beyond that, we'd need to look at the relevant python runtime related channels for the notebook in the Output tab of the Panel to see if there are any hints as to what happened.

petetronic avatar Jul 15 '24 21:07 petetronic

I think I reproduced..

image

image

Left is the jupyter noteook file which I created before using Positron Right is the jupyter notebook file which I created using Positron.

As you see, both notebook using same python environment.

RayleighKim avatar Jul 17 '24 02:07 RayleighKim

I think I successfully reproduced, even though I didn't want to.....

image

I saved jupyter notebook on the right ( I mentioned above... that had not been not saved)

Now code suggestion is gone...

Spec: Windows11 python 3.8.13 Positron-2024.07.0-52

I attached my python environment yaml file. yamlfile.zip

RayleighKim avatar Jul 17 '24 02:07 RayleighKim

same here - autocomplee works in python .py file but not in jupyter notebook .ipynb

PhilippFW avatar Jul 17 '24 06:07 PhilippFW

Hmmmm, if you are experiencing this problem, could you go to "Output" and choose the channel for your notebook? It will look something like this:

Screenshot 2024-07-17 at 3 51 05 PM

Could you save that log and attach it as a file to a comment here? We're especially interested in what these notebook logs say about the LSP server. Mine, with working autocomplete, says near the beginning:

[Positron] Starting Positron LSP server on port 46057
[Positron] Starting LSP server positron-lsp-python-2-8f657d76 for 127.0.0.1:46057
[Positron] Creating 'positron.lsp' client for Python
[Positron] SEND comm_open to Shell: {"buffers":[],"content":{"target_name":"positron.lsp","comm_id":"positron-lsp-python-2-8f657d76","data":{"client_address":"127.0.0.1:46057"}},"header":{"msg_id":"72634796-6f97-403d-be0d-3ca5d4ae185a","msg_type":"comm_open","version":"5.0","date":"2024-07-17T21:46:39.365Z","session":"5dc885ad16f7276fa0abd509a20e03a6","username":"juliasilge"},"metadata":{},"parent_header":{}}

juliasilge avatar Jul 17 '24 21:07 juliasilge

I truly want to use positron...

image Output_Log.txt

image Output_Log2.txt

RayleighKim avatar Jul 18 '24 02:07 RayleighKim

Thanks for sharing the logs! I can't see anything suspicious from those. Could you please try updating the python.languageServerLogLevel setting to debug and sharing the logs if it fails again? Note that you will have to wait for it to happen again since the log level will only be set for future sessions.

seeM avatar Jul 18 '24 11:07 seeM

Thanks for sharing the logs! I can't see anything suspicious from those. Could you please try updating the python.languageServerLogLevel setting to debug and sharing the logs if it fails again? Note that you will have to wait for it to happen again since the log level will only be set for future sessions.

I'm sorry, Could you please show me how to do it? I'm so new to this IDE that I don't know how to set.

If you could let me know how, then I would share the whole logs again. Sad to say, it's very easy for me to reproduce...

edit>> image is it right setting?

image I think I reproduced again.

this is the log Output_Log3.txt

RayleighKim avatar Jul 22 '24 02:07 RayleighKim

Thanks! You will also need to close and reopen Positron, since I see in the logs that it hasn't taken effect yet i.e. --loglevel error.

seeM avatar Jul 22 '24 12:07 seeM

image Output_Log4.txt

I hope that any suspicious parts are found in this log. If there's anything additional you would like me to try, please let me know. I will try and upload the log again.

RayleighKim avatar Jul 23 '24 11:07 RayleighKim

Thank you for sharing the log! I can't figure out how to reproduce the issue from the logs, but there are clues:

  1. So far we've only seen this reported on Windows.
  2. The LSP server successfully starts, accepts the connection from the editor, initializes, and receives a workspace/didChangeConfiguration message.
  3. No textDocument/didOpen LSP messages are received. On my laptop, I see one textDocument/didOpen message for each cell in the notebook, and numerous textDocument/didChange as I type. This makes me think that the problem is on the client side.

Could you please also share the log file for the "Python" output channel? You can run the "Output: Show Output Channels..." command and then select "Python".

seeM avatar Jul 23 '24 15:07 seeM

image image image

Log_Console.txt Log_Notebook.txt Log_Python.txt

Something different happened this time. Positron asked me to install ipykernel, and I accepted. (it was my first time to see this.) It was not helpful anyway. All the screenshots and the logfiles in this comment were made after installing ipykernel.

RayleighKim avatar Jul 24 '24 01:07 RayleighKim

Thank you again @RayleighKim! I've created PR #4137 with a potential fix for this issue but have not yet been able to verify it on a Windows computer. We'll post follow-up messages here as the PR goes through verification.

seeM avatar Jul 24 '24 15:07 seeM

Thank you.

To be honest, I'm not very familiar with GitHub(and opensource communication culture..), so I might have ignored many guidelines/rules of writing issue comment. Even so, thank you for guiding me on exactly what I need to do. If there's anything else that needs to be checked or tested, please let me know.

RayleighKim avatar Jul 24 '24 16:07 RayleighKim

I am noticing the same issue in Quarto markdown with R code in Windows. I searched and landed on this issue. I think this is being actively worked on but I am sharing screenshots in case they help. Let me know if sharing any logs would help.

Autocomplete in question is for a variable that exists in the current session environment. Console works but editor doesn't. image image

piyuranjan avatar Jul 26 '24 19:07 piyuranjan

@piyuranjan That is a pretty different problem, I believe. Do you mind opening a new issue with your details? If you are able to recreate the problem with a pretty minimal Quarto file (i.e. short) and latest Positron build that would be super helpful.

juliasilge avatar Jul 29 '24 18:07 juliasilge

@juliasilge, thank you for responding! You are correct that this is a different problem. I was able to get to the source when I was trying to create a minimal example. The issue is caused when a code block is inside a callout and they both end at adjacent lines (without an extra new line between them). This causes the autocomplete/intellisense in Positron to completely stop after it has happened in the markdown. I am unsure if this is a Positron or Quarto issue. Let me know if I should open a new issue with Positron. I couldn't find any mentions of this with Quarto as well. Edit: I should also add that Quarto's visual editing is taking the empty lines out. So adjacent code-callout begin/ends are expected.

piyuranjan avatar Jul 30 '24 14:07 piyuranjan

@piyuranjan That is a a Quarto VS Code extension issue, and especially the problem where the visual editor takes out the empty line (I predict they will say it is normal to need the extra line). Can you open an issue outlining your problem there? https://github.com/quarto-dev/quarto/issues

juliasilge avatar Jul 30 '24 15:07 juliasilge

Verified Fixed

Positron Version(s) : ?
OS Version          : Windows

Test scenario(s)

Marking as verified based on Pete's note on the PR.

Link(s) to TestRail test cases run or created: N/A

testlabauto avatar Aug 01 '24 20:08 testlabauto

Thank you all for fix.

I want to know which version that I can use.

RayleighKim avatar Aug 02 '24 01:08 RayleighKim

Hi @RayleighKim ,

Please try 2024.07.0-125 We verified this issue with a dev build but it should be fixed in 125.

Please let me know if you still see issues.

Thank you for your report!

testlabauto avatar Aug 02 '24 15:08 testlabauto