vscode jupyter strange autocomplete "%%!" - python

in jupyter
I recently updated it, and there is a problem when Jupyter performs automatic completion.
in editor
As shown in the picture above, there is no problem unless it is Jupyter.
Why does this %%! occur?
Downgrade does not change to normal now.
os: EndeavourOS Linux x86_64 5.13.13-arch1-1
vscode version: 1.60.0
jupyter extension version: 2021.8.2041215044

This happens because the "enter" is being used to accept the suggestions instead of "tab". You can fix this following these steps:
Click in "File" > "Preferences" > "Ctrl[+,]".
Fill the search bar with this text "Accept Suggestion on Enter".
The actual value set in checkbox could be "on" or "smart", switch to "off".
This must resolve your problem.

It's jupyter notebook related, such as # %% to create a new cell.

Related

Python code is not syntax highlighted in Pycharm notebook?

In the screenshot we see a pretty normal-ish python code cell within the Pycharm notebook viewer The viewer "understands" the notebook: it is bringing up the managed Jupyter server option and knows this is [python] code:
So then where did the syntax highlighting go to? How can it be [re-]enabled ?
#Wayne was headed the right direction: that link he provided Wrong Code Highlighting in Jupyter Notebooks had suggestion to reload the python interpreter.
Well in my case the interpreter is Synapse Pyspark and is grayed out since i'm presently running locally. I need to figure out how to change the interpreter: will update here at that point.
Update I needed to edit the json source of the ipynb file to find and remove the synapse kernel.

Missing 'Find in Selection' in VS Code when editing Jupyter Notebooks

The 'find in selection' button is missing from VSCode when working with Jupyter Notebooks. It slows down development so I would like to ask if anybody knows how to activate it?
First image shows the search/replace when in a python file. Second image shows the missing button when in a notebook.
Python file:
Jypyter Notebook:
The .ipynb file is written by a kind of markdown.
The only way is to rightclick the tab and reopen .ipynb by builtin text editor for now.
As Jan 2022, within a cell in a jupyternotebook you can search and replace in selection when pushing F3. As comment before, this function is not available when using Ctrl + H
More info :
How to find and replace text in a single cell when using Jupyter extension inside Visual Studio Code
https://github.com/microsoft/vscode/issues/141493
https://github.com/microsoft/vscode/issues/121218

Parameters of python's functions doesn't appear when I hit 'tab'

It might sound stupid, but the jupyter notebook I'm using is, probably, not configured as it should.
Everytime I hit 'tab' when the cursor is within a function, the parameters doesn't appear in the top of the list. Any tip here?
enter image description here
Found this on stack over flow TAB completion does not work in Jupyter Notebook but fine in iPython terminal
are you using firefox aswell?
the solution seems to be to run:
pip3 install jedi==0.17.2

VSCode: Code Lens for Jupyter Notebook does not show debug option or "run code by line"

I am still new to vscode, but I am having trouble getting some of the tools for python Jupyter notebooks to work in VSCode Version: 1.56.2 on ubuntu linux 20.04 LTS.
So according to the documentation, there are supposed to be buttons for debugging, including a button to "run code by line". This makes it easier to debug any code issues in a notebook cell. The documentation suggests the notebook interface should look like this.
The buttons in the upper left are the ones that I am interested in.
Now, when I look at my own interface, it looks like this.
So the two interfaces look very different. I am not sure if I need to change any settings in VSCode to enable these buttons. The documentation did not mention changes to any settings.
Any suggestions would be appreciated.
"Run code by line" has not yet been implemented for the new notebooks interface that you are seeing. In the meantime, you can opt back into the old interface with "Run code by line" support by doing the following:
Open your user settings.json by typing Ctrl+Shift+P > "Preferences: Open Settings (JSON)"
Add the following line to your user settings.json file:
"jupyter.experiments.optOutFrom": ["NativeNotebookEditor"]
If the workbench.editorAssociations setting is present in your settings.json file, delete it.
Reload VS Code for the new settings to take effect
In vscode 1.59 (see https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_59.md#jupyter-run-by-line)
Jupyter "Run By Line"
We've been working on supporting the "Run By Line" feature in Jupyter
notebooks. This feature is essentially a simplified debug mode that
lets you step through your cell's code line by line without any
complex debug UI. This is still experimental, but you can try it out
by setting "jupyter.experimental.debugging": true, installing
version 6 of ipykernel in your selected kernel, then clicking the "Run
By Line" button in the cell toolbar.
"jupyter.experimental.debugging": true
Of interest
We have been working on supporting debugging in Jupyter notebooks, so
that you can set breakpoints in notebook cells, execute cells
step-by-step, and use all other VS Code debugger features. This is
experimental, but you can try it out by setting
"jupyter.experimental.debugging": true, installing version 6 of
ipykernel in your selected kernel, then clicking the "Debug" button in
the notebook toolbar.
in vscode v.158, https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_58.md#jupyter-notebook-debugging
Make a debug point and just press F10 ; Debug will started automatically

VSCode Jupyter: is there a way to make python interactive window work as default console?

I've recently switched to VSCode, and am wondering if there's a way to make the Python Interactive Window from the Jupyter support in VSCode work like the console in Spyder where I just have to select code and press ctrl+enter to send it, without having to create cells everytime.
For now I'm resigned to work with the Terminal until my code is clean and then create a cell when I have reusable code, and would like to just work directly with the PIW.
You can always change the default console setting by:
Opening the Command Palette (⇧⌘P)
Typing "Preferences:Open Settings (JSON)
Edit this line:
"python.dataScience.sendSelectionToInteractiveWindow": false
You should be able to do this with the latest python extension. The select the code you want to execute and press shift-enter. Is that not working?
For me (now) interactive mode runs after setting "jupyter.sendSelectionToInteractiveWindow": true
#FranciscoRZ. You should have seen a popup option for this, but if it didn't come up for you it can just be manually set in VSCode options. Just change this guy here:
Python->Data Science: Send Selection To Interactive Window
That should get you what you are looking for.
OP's Note: Accepting this answer because it will be the right anwser starting with the February release of VS Code Python
If you have the notebook saved as a python percentage script (which is more git friendly)
each "cell" will be delimited by # %% and the default run command is "Shift+Ctrl".
Later once you are working in the interactive window, If you want a particular cell you wrote on the fly to be in you script, there is one button which says "Paste code into file" right next to the recently executed cell in the interactive window.
And in case you are using the notebook for the sake of being able to later export it to html or pdf, once executed in the interactive window, there is an export button as well.

Categories

Resources