posit-dev / positron

Positron, a next-generation data science IDE
Other
2.42k stars 73 forks source link

Error opening the viewer for pandas dataframe in Quarto document #4347

Closed Matteo-Valerio closed 3 weeks ago

Matteo-Valerio commented 1 month ago

System details:

Positron and OS details:

Positron Version: 2024.08.0 (system setup) build 31 Code - OSS Version: 1.91.0 Commit: 7ee0596b81d578059e63c9af7c535c6b6040b947 Date: 2024-08-10T13:58:22.910Z Electron: 29.4.0 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Windows_NT x64 10.0.22621

Interpreter details:

Python 3.10.9

Describe the issue:

In a Quarto document, running the Python code reported below to create a pandas dataframe, it’s not possible to visualize the data in the viewer.

image

The code is executed correctly, and in the console the results are presented as expected.

image

When clicking on the grid icon to visualize the data, an error message is displayed.

image

image

Were there any error messages in the UI, Output panel, or Developer Tools console?

Yes

seeM commented 1 month ago

Thanks for the report @Matteo-Valerio! I'm unable to repro this on macOS with Positron Version: 2024.08.0 (Universal) build 31.

Have you tried restarting the session e.g. by running the "Interpreter: Restart Interpreter" command or the keyboard shortcut Ctrl+Shift+0.

EDIT: If you installed pandas in the current session, you'd need to restart the session before the data explorer will work.

Matteo-Valerio commented 1 month ago

I'm using Win 11, and even if I restart the session the data explorer doesn't work. Thank you

seeM commented 1 month ago

Hmm, I'm unable to repro on Win 11 as well. Could you please share the Python kernel logs? That could give us a clue about what's going wrong.

You'll need to do the following:

  1. Set the kernel log level setting to debug. You can search the settings for python.languageServerLogLevel to find it.
  2. Completely close and reopen Positron to let it take affect.
  3. Reproduce the error.
  4. Share the kernel log file here, which you can find by running the "Interpreter: Show interpreter output" command. It's worth making sure there is no confidential info in the logs before sharing.
Matteo-Valerio commented 1 month ago

Following I report the interpreter's output.

Thank you


[Positron] SEND comm_msg to Shell: {"buffers":[],"content":{"comm_id":"positron-variables-python-7-3c9506b1","data":{"jsonrpc":"2.0","method":"view","params":{"path":["{\"type\":\"str\",\"data\":\"df\"}"]}}},"header":{"msg_id":"a8be1887-eec0-4e25-adb7-5c2ef19af318","msg_type":"comm_msg","version":"5.0","date":"2024-08-19T09:20:17.401Z","session":"bd729d1ef179cc0a3a2f6fd1fa2073cb","username":"curr_user"},"metadata":{},"parent_header":{}} [Positron] SEND comm_msg: OK [Positron] Python kernel status changed: idle => busy [Positron] RECV status/busy from iopub: {"header":{"msg_id":"ddcfb13a-da7ffa79e0940aff11ddde61_15564_33","msg_type":"status","username":"username","session":"ddcfb13a-da7ffa79e0940aff11ddde61","date":"2024-08-19T09:20:17.402656Z","version":"5.3"},"parent_header":{"msg_id":"a8be1887-eec0-4e25-adb7-5c2ef19af318","msg_type":"comm_msg","version":"5.0","date":"2024-08-19T09:20:17.401000Z","session":"bd729d1ef179cc0a3a2f6fd1fa2073cb","username":"curr_user"},"metadata":{},"content":{"execution_state":"busy"},"buffers":[]} [Positron] RECV comm_msg/positron-variables-python-7-3c9506b1/undefined from iopub: {"header":{"msg_id":"ddcfb13a-da7ffa79e0940aff11ddde61_15564_34","msg_type":"comm_msg","username":"username","session":"ddcfb13a-da7ffa79e0940aff11ddde61","date":"2024-08-19T09:20:17.402656Z","version":"5.3"},"parent_header":{"msg_id":"a8be1887-eec0-4e25-adb7-5c2ef19af318","msg_type":"comm_msg","version":"5.0","date":"2024-08-19T09:20:17.401000Z","session":"bd729d1ef179cc0a3a2f6fd1fa2073cb","username":"curr_user"},"metadata":{},"content":{"data":{"jsonrpc":"2.0","error":{"code":-32603,"message":"Error opening viewer for variable at '['{\"type\":\"str\",\"data\":\"df\"}']'. Try restarting the session."}},"comm_id":"positron-variables-python-7-3c9506b1"},"buffers":[]} [Positron] Python kernel status changed: busy => idle [Positron] RECV status/idle from iopub: {"header":{"msg_id":"ddcfb13a-da7ffa79e0940aff11ddde61_15564_35","msg_type":"status","username":"username","session":"ddcfb13a-da7ffa79e0940aff11ddde61","date":"2024-08-19T09:20:17.407674Z","version":"5.3"},"parent_header":{"msg_id":"a8be1887-eec0-4e25-adb7-5c2ef19af318","msg_type":"comm_msg","version":"5.0","date":"2024-08-19T09:20:17.401000Z","session":"bd729d1ef179cc0a3a2f6fd1fa2073cb","username":"curr_user"},"metadata":{},"content":{"execution_state":"idle"},"buffers":[]} [Python] [PositronIPKernelApp] [Python] MESSAGE TYPE:comm_msg [Python] [PositronIPKernelApp] Content: {'comm_id': 'positron-variables-python-7-3c9506b1', 'data': {'jsonrpc': '2.0', 'method': 'view', 'params': {'path': ['{"type":"str","data":"df"}']}}} [Python] ---> [Python]
[Python] [PositronIPKernelApp] comm_msg: {'header': {'msg_id': 'a8be1887-eec0-4e25-adb7-5c2ef19af318', 'msg_type': 'comm_msg', 'version': '5.0', 'date': datetime.datetime(2024, 8, 19, 9, 20, 17, 401000, tzinfo=tzutc()), 'session': 'bd729d1ef179cc0a3a2f6fd1fa2073cb', 'username': 'curr_user'}, 'msg_id': 'a8be1887-eec0-4e25-adb7-5c2ef19af318', 'msg_type': 'comm_msg', 'parent_header': {}, 'metadata': {}, 'content': {'comm_id': 'positron-variables-python-7-3c9506b1', 'data': {'jsonrpc': '2.0', 'method': 'view', 'params': {'path': ['{"type":"str","data":"df"}']}}}, 'buffers': []} [Python] [Comm] handle_msg[positron-variables-python-7-3c9506b1]({'header': {'msg_id': 'a8be1887-eec0-4e25-adb7-5c2ef19af318', 'msg_type': 'comm_msg', 'version': '5.0', 'date': datetime.datetime(2024, 8, 19, 9, 20, 17, 401000, tzinfo=tzutc()), 'session': 'bd729d1ef179cc0a3a2f6fd1fa2073cb', 'username': 'curr_user'}, 'msg_id': 'a8be1887-eec0-4e25-adb7-5c2ef19af318', 'msg_type': 'comm_msg', 'parent_header': {}, 'metadata': {}, 'content': {'comm_id': 'positron-variables-python-7-3c9506b1', 'data': {'jsonrpc': '2.0', 'method': 'view', 'params': {'path': ['{"type":"str","data":"df"}']}}}, 'buffers': []}) [Python] [positron_ipykernel.variables] ERROR | module 'sqlalchemy' has no attribute 'Engine' [Python] Traceback (most recent call last): [Python] File "c:\Program Files\Positron\resources\app\extensions\positron-python\python_files\positron\positron_ipykernel\variables.py", line 580, in _perform_view_action [Python] if self.kernel.connections_service.object_is_supported(value): [Python] File "c:\Program Files\Positron\resources\app\extensions\positron-python\python_files\positron\positron_ipykernel\connections.py", line 289, in object_is_supported [Python] return safe_isinstance(obj, "sqlite3", "Connection") or safe_isinstance( [Python] File "c:\Program Files\Positron\resources\app\extensions\positron-python\python_files\positron\positron_ipykernel\utils.py", line 253, in safe_isinstance [Python] m = getattr(m, attr) [Python] AttributeError: module 'sqlalchemy' has no attribute 'Engine'. Did you mean: 'engine'? [Positron] SEND heartbeat with timeout of 30 seconds [Positron] SEND heartbeat with timeout of 30 seconds [Positron] SEND heartbeat with timeout of 30 seconds

seeM commented 1 month ago

Ah! This looks like a bug, where we're not handling an unexpected (possibly older) version of sqlalchemy.

testlabauto commented 3 weeks ago

Verified Fixed

Positron Version(s) : 2024.08.0-77
OS Version          : OSX 

Test scenario(s)

Verified with original filing instructions

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