VSCode Jupyter Notebook syntax highlighting and autocompletion stopped working - python

So, I've been using VSCode for Jupyter notebooks for almost a year and a half now, and it always used to work normally, but a couple of days ago it just got broken, and I don't know why. Here's what I mean:
Jupyter Notebook on VSCode
As you can see, there's no syntax highlighting, and autocompletion doesn't work at all... but if I run the code, it does run perfectly.
It works normally in Python scripts though:
Normal Python Script
Relevant Extensions I've got:
Jupyter (+ Keymap & Notebook Renderers)
Python
Pylance
I've got a bunch of others for C++ and Java.
Also, I've noticed that both Jupyter and Python extensions give an uncaught error, here's what I mean:
Jupyter Extension Error
Python Extension Error
I have no clue what any of this means. I've tried uninstalling and re-installing the extensions, re-installing VSCode, resetting settings.json and restarting my laptop, nothing worked.
Any help will be highly appreciated. Thanks

Do you have installed the extension of Dependency Analytics? You need to disable it.
Some people have run across the same problem, you can refer to here.

Related

How can I visualize image using qiskit in vscode?

I'm now trying to run qiskit visualization functions(e.g. .draw() methods) in vscode.
I use latest version of Python, 3.11.1, and followed Getting Started Qiskit in here.
Also I installed qiskit extension in vscode.
However, when I run a qiskit code, the visualization functions don't work, even though code is compiled successfully.
I checked visualizing modules(mathplotlib, etc.) were installed.
I tried to re-install Python and vscode, including downgrading Python to 3.8. And it didn't work.
Additionally, qiskit-chemistry and qiskit-aqua installation warnings are pop-upped, but installation doesn't work.
I really don't know it is related on this problem, but I think maybe it's not since qiskit-aqua is deprecated.
The following screenshot is result of the qiskit test code.
result of running
draw() and plot_histogram() doesn't work as you can see.
How can I fix this problem?
These functions are meant to be used in Python Notebooks - they won't show up in normal .py files. Try using VSCode's Jupyter Notebook (.ipynb files) feature instead.

VSCode Jupyter not connecting to python kernel

Launching a cell will make this message appear: Connecting to kernel: Python 3.9.6 64-bit: Activating Python Environment 'Python 3.9.6 64-bit'. This message will then stay up loading indefinitely, without anything happening. No actual error message.
I've already tried searching for this problem, but every other post seem to obtain at least an error message, which isn't the case here. I still looked at some of these, which seemed to indicate the problem might have come from the traitlets package. I tried to downgrade it to what was recommended, but it didn't solve anything, so I reverted the downgrade.
The main problem here is that I have no idea what could cause such a problem, without even an error message. If you think additional info could help, please do ask, I have no idea what could be of use right now.
Not sure what did the trick but downgrading VSCode to November version and after that reinstalling Jupyter extension worked for me.
i've just found out it's solved by simply just right clicking on code.exe, set to 'run as administrator', and done.
If anyone has the same problem, before reinstalling VSCode as the accepted answer said, try closing and reopening VSCode first.
That worked for me, saving me the agony of having to reinstall VSCode.
I am using mac.os. I moved vscode from the download folder to the application folder. This solved my problem.
On the VSCode download page, there are two Windows installer types: 'User Installer' and 'System Installer'.
I had VSCode installed in AppData folder, using user installer. On the OP's problem occurrence, I tried to restart, reinstall and downgrade VSCode, as other answers suggested, but nothing helped.
Finally, I tried with System Installer. It requires elevated privileges during installation and installs VSCode in Program Files folder. That solved the problem for me.
So, one may try with different installation type.
None of the previous answers are working for me (windows 10 + python 3.10.9 + VSCode x64-1.74.3). What made things work was downgrading VS Code. I arbitrarily chose VSCode x64-1.66.2

jupyter notebook not showing python option under new

I am having a problem with creating a new ipython notebook.
Previously I used to do that going to new -> python
but now I am unable to see any python option.
Also, I am unable to open any ipython notebooks, I have one uploading for hours now.
I recently erased my %temp% folder to free some space in the C drive. Does that have something to do with this? How do I fix this?
I solved the problem!
For some reason, jupyter labs was not installed
So running the command
jupyter -- version
and then checking what all was installed, I found out that jupyter labs was not installed?
pip3 install jupyter labs
so I went ahead and installed it and everything works as it did before.
Still don't know the reason why this all happened in particular. If anyone could help me with that'd be awesome!
I'm not sure 100% but this is most commonly related to an ipython jupyter notebook file error. I do recommend to do a clean install of the notebook and try again. As I don't have any specifications on your system is difficult to guide you on the process. But that is the best option you have now.
Also this could have happened because of an update on python, jupyter, your system or any base component required by jupyter or python.

Add autopep8 and linting to jupyter in VS code python notebook

Question
Error highlighting and autoformatting can be great tools to help one create great notebooks. I am trying to change the settings on the VS code to allow me to autoformat to pep8 in my python notebooks.
On this page for Jupiter notebooks have found that I have to put some lines in my .json files in the settings>preference of VSCode in order to do this. I am particularly interested in changing my code to the pep8 coding convention and also adding linting in order to highlight errors.
linting (error highlighting)
autoformatting (autopep8)
I am using VS Code on Ubuntu 18.04. Below is my attempt that led to an error "Code language not supported or defined".
Attempt
After installing the Python extension and the autopep8 extension in VS code and running
pip3 install autopep8
I got an error message and was unable to use pep8.
If you may know how to set up an efficient working environment in VS Code for Jupyter notebooks I would really appreciate any assistance
Summary
How to set up:
linting (error highlighting)
autoformatting (autopep8)
in VS code for python notebooks.
Edit 1:
I also tried running autopep8 in the command palette and got the error
Command 'autopep8' resulted in an error (Running the contributed command: 'extension.sayHello' failed.)
Nbextensions are notebook extensions and only work within the notebook itself. VS Code does not support native notebooks so these extensions won't work at the time. They are planning to add it in future releases per link

Visual Studio Code syntax highlighting not working

I am using Visual Studio Code (VSC) as my IDE. My computer just updated to Catalina 10.15.2 (19C57) and since the update, now VSC is not highlighting syntax errors. The extensions I have seem to be working and it recognizes my miniconda python environment.
Is there a solution for this yet? I was avoiding Catalina as I know it has caused lots of errors, but now that I was forced to install it I need a solution as I love VSC.
I also had the same problem for typescript react files. Tried many things and nothing worked. Finally I checked the extensions I've installed for typescript react. Disabling JavaScript and TypeScript Nightly extension worked for me
In my case, the Catalina installation didn't remove my Python installation.
After checking as suggested by #Brett Cannon in his comment, the update to Catalina uninstalled some extensions from VS Code. These are not available in the VS Code extension Marketplace anymore, so there must be an issue regarding compatibility. I fixed it after I opened my command palette (Command + Shift + p) and typed python: select linter. Then selected pylint, selected the install with conda option, Close/Open VS Code and now it's working(though it's still not shown in my extensions section in VS Code). It's necessary to point out that you will have to install pylint in every Python environment you are using. In my case I have multiple Conda environments.
It's very specific but for me it was a missing semicolon in my css (styled-component). I use styled-components in react and it didn't throw an error for missing semicolon but highlighting was suddenly gone.
I had given up and left it that way until I came up with the solution quite by accident.
If you were using the global install of Python then that was removed in Catalina which would break your virtual environment. A new install of Python and recreating the virtual environment should fix things.
Had similar issue on new vscode setup - my problem was rather that eslint warnings are not being highlighted, only errors.
After opening my eslint setup for the project - .eslintrc.js file, saw message saying that eslint needed permission accessing some files, which I did by clicking the lightbulb next to module.exports and hitting accept button.

Categories

Resources