How can I get Jupyter-notebook syntax highlighting in VS code? - python

I installed Visual Studio Code, and want to customize syntax highlight to be the same as Jupyter notebook. I'm using default light theme and that's good but colors of python built-in functions and methods aren't.
What should I do?

Since the code itself is written in python, as long as you have the language support you should get the Syntax Highlighting, Autocomplete and IntelliSense. See: https://code.visualstudio.com/docs/languages/python.
For a full walkthrough on setting up a jupyter-notebook see: https://code.visualstudio.com/docs/datascience/jupyter-notebooks

Seems there is a theme for that on the VS Code extensions site. You should be able to install it from the extensions tab on VS Code itself or through "Install" from that link.
Hope this helps.

Related

How to get Intellisense on Visual Studio (VS) Code to work on Python

I have Visual Studio Code on my laptop and setting it up for the first time and am having trouble making Intellisense work. I downloaded the python extension. When I tried to type a syntax, I don't see a drop down of the available methods.
What I did so far was press F1> type 'open settings'> and see that the option is turned on. It looks like the setting is on, screenshot below line 18. I'm not sure if there is something I'm missing. Would anyone happen to have an idea of how I can have the auto complete functionality to work?
Intellisense was provided by the Language Server, The default value of it is Default.
Default: Automatically select a language server: Pylance if installed
and available, otherwise fallback to Jedi.
So, it's a little weird of your problem, could you try to install the Pylance and set it as the Language Server? Add this in the settings.json file:
"python.languageServer": "Pylance",
Have you tried Ctrl+Space or hovering some code?
Also do you have "Visual Studio IntelliCode" extension installed?
If neither Ctrl+Space nor hovering work, it is recommended to restart VS Code (https://code.visualstudio.com/docs/editor/intellisense#_troubleshooting)

VS code python attribute suggestion

I have a problem with Intellisense. Even though Python, Pylance and even Visual Studio IntelliCode extensions are installed, VS code is still unable to suggest object attributes.
Could you please advise any settings.json parameters which will trigger python attribute suggestion globally ?
Sometime it's tedious to remember all object attributes without documentation being opened.
You can use ctrl + space for windows for activating intelliSense in VsCode.
However it also depends on processing speed of computer.
Intellisense was provided by the Language Server. The search paths depend on the python interpreter you have selected.
If you modify the PYTHONPATH manually to import the package, you need to add these locations to the Language Server too(settings.json), like this:
"python.autoComplete.extraPaths": [
"C:/Program Files (x86)/Google/google_appengine",
"C:/Program Files (x86)/Google/google_appengine/lib/flask-0.12"]
You can refer to here.
Or, there are some problems of your Language Server, you can have a look at the
OUTPUT panel --> Python Language Server channel. And attach the error message on the question.
Open the Command Palette (Command+Shift+P on macOS and Ctrl+Shift+P on Windows/Linux) and type:
Python: Select Interpreter
then choose Interpreter.

Python note book autocomplete not working in VSCode with environment being CVE

I have done some research, but none of the solutions work for me and it seems that my situation is much worse than everybody else. Currently, my VSCode editor is just acting like a plain text editor for any ipynb files. For example, this is how my import block looks like:
Nothing has been highlighted, and I'm working with this for quite a long time and now I can't bear with this anymore. If this is not bad enough, then take a look at the following:
Literally, nothing happens. I think now the only help I get from VSCode is plain text auto-completion, but that is far from what anyone should have.
The configuration is pretty simple. I have the following kernels I can choose from:
And I'm mainly using anaconda3 for my kernel. Further, I only have
in my setting.json for python configuration.
As for extension, I have the standard python extension with python extension pack installed, which are the only two extensions I installed for python.
I'm really tired of working with plain text python code, if any information is needed, I can provide as much as I can.
-- Edit
It seems that the default language is not python, but CVE. Futhermore, I can't find the proper language to choose. All the language options are listed below.
The error happened because of the extension Dependency Analytics. Please uninstall it and reload window.
Reference: jupyter conflict with Dependency Analytics.
Click here and select Python.
CVE seems to be the default language for notebooks for some reason. Please check the settings.

VS Code syntax highlighting Python f-strings

I've been using VS Code for Python for a while now, but after all this time I still haven't figured out how to syntax highlight my f-strings. I've seen screenshots of other people who have them highlighted properly, but mine look like this:
Is this something I have to manually change in my color scheme?
Can it output the correct result? In other words, f-string can work?
Have you tried to switch the color theme?
And can you open the Command Palette to execute the command of Developer: Inspect Editor Tokens and Scopes to get this:
Can you find the meta.fstring.python like the above picture?
This could be provided by the Built-in extension of Python Language Basic or MagicPython extension and so on. So could you disable all the python related extensions then only enable the Python and Built-in extension of Python Language Basic to make a try?
You can try changing the theme of VSCode. I usually use the Github theme and I can see proper syntax highlight. Also, make sure all the necessary extensions for python are installed.
Screenshot from VS Code

How to get syntax highlighting for .enaml files in PyCharm?

I am trying to learn Enaml, which is an extension to the Python language that allows you to define hierarchical trees of objects used for graphical user interfaces.
Since enaml is a super-set of the Python language, its syntax can be different from Python's one and IDEs do not highlight it.
Is there any way to get enaml-syntax highlighting in PyCharm? Or maybe in some other IDE?
(I know that the package 'enaml-pygments' exists, but I have no idea how to make it work for automatic enaml-syntax highlighting in an IDE.)
I've added most of the keywords to this repo which you can import into PyCharm:
There are highlighters for a few editors in the Enaml repo. Maybe one of them can be used by PyCharm: https://github.com/nucleic/enaml/tree/master/tools
Today I found this settings menu that partially addresses the issue of adding any syntax to PyCharm:
https://blog.jetbrains.com/idea/2010/09/custom-file-types-in-intellij-idea/
Unfortunately it captures only the most simple features of a syntax.
I'm using Atom to work with Python/Enaml code. With the language-enaml package you get syntax highlighting plus some autoextension and docstring feature for Enaml (https://atom.io/packages/language-enaml). Add in git integration and packages like build-python to run you code from the editor and you have quite a nice IDE.
https://github.com/vahndi/pycharm-enaml-keywords
Open PyCharm
Go to File,
Import Settings...,
browse to the .jar file and click OK
Select All,
OK

Categories