My script begins with the following:
# %%
%matplotlib qt
import importlib
import sys
import matplotlib.pyplot as plt
I am using visual studio code. The script is not a .ipynb file, but a simple .py script. When I use the utility to run the block as a cell, everything works fine, but when I try to run the whole, I get an the following error:
"resource": "/c:/Users/Ariel/Documents/Courses/Tesi/Code/002-test_preprocessing.py",
"owner": "_generated_diagnostic_collection_name_#2",
"severity": 8,
"message": "Expected expression",
"source": "Pylance",
"startLineNumber": 2,
"startColumn": 1,
"endLineNumber": 2,
"endColumn": 2
My VSCode version is
Version: 1.78.2 (user setup)
Commit: b3e4e68a0bc097f0ae7907b217c1119af9e03435
Date: 2023-05-10T14:39:26.248Z
Electron: 22.5.2
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.22621
Sandboxed: No
I tried to substitute the line with
import matplotlib
matplotlib.use('Qt5Agg')
but this time I have the problem that if I run this ac cell. The plots open in new windows, but I have no way to stop the execution of the cells.
I also tried to run again
pip install pyqt5 --upgrade
pip install matplotlib --upgrade