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
Related
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.
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
Is there a Python auto import extension/plugin available for Visual Studio Code?
By auto import I mean, auto import of python modules. Eclipse and Intellij has this feature with Java.
VSCode team recently released Pylance
Features
Docstrings
Signature help, with type information
Parameter suggestions
Code completion
Auto-imports (as well as add and remove import code actions)
As-you-type reporting of code errors and warnings (diagnostics)
Code outline
Code navigation
Code lens (references/implementations)
Type checking mode
Native multi-root workspace support
IntelliCode compatibility
Jupyter Notebooks compatibility
No, but it will soon be a part of vscode-python: https://github.com/Microsoft/vscode-python/pull/636
EDIT: See answer by #Eric, who built such an extension.
EDIT 2: See answer by #Eyal Levin, mentioning such an extension (Pylance).
I have built an automatic import extension that supports Python. It lets you fully customize how the imports get written to the file, modifying import paths, names, sorting relative to other imports. The Python plugin even lets you "group" imports together with extra line breaks.
From https://github.com/microsoft/python-language-server/issues/19#issuecomment-587303061:
For those who wonder how to trigger auto-importing as I did, here are
the steps.
Enable Microsoft Python Language Server by removing the check of
Python: Jedi Enabled in your settings.
Reload the VSCode window.
Hover your mouse over the variable that you want to import, and click Quick
fix...
For the last step, if it shows No quick fixes available or
Checking for quick fixes, you may need to wait for a while until the
extension has finished code analysis. It is also possible to set a
shortcut that triggers a quick fix.
I use this package it works very well
https://marketplace.visualstudio.com/items?itemName=codeavecjonathan.importmagic
You can find it in VSCode extension store. it's name is IMPORTMAGIC. It works fantastic. It will include all modules which you use in your script.
It has code action ctrl + . , which will also import library.
This is supported in the official Microsoft python extension, but for some reason I found it was recently disabled or no longer default. The setting I had to toggle was
"python.analysis.autoImportCompletions": true,
(Updated answer as of January 2023)
These three together did it for me:
"python.analysis.autoImportCompletions": true,
"python.analysis.autoImportUserSymbols": true,
"python.analysis.indexing": true,
If that is slowing down your computer too much because it's indexing too many files, then look into specifying patterns and depths of directories to include in the indexing using "python.analysis.packageIndexDepths".
Note that I am using Pylance (currently the default, as of January 2023).
Check out the VSCode python settings reference for more info on each of those settings.
You might find This Python-Based Module useful if you wish to auto import and auto download missing modules from a script or sub-scripts. Not only for VSCode, but also for any IDE or Editor.
I was wondering if it is possible to use PyDev in Sublime. Because it has all this great debugging features that are missing in Sublime.
I know that it hasn't been implemented but I think with a few tricks we can use PyDev in Sublime.
There is also SublimeREPL plugin which allows you to run an interpreter inside Sublime.
https://github.com/wuub/SublimeREPL
Moreover, there is this remote debugging ability from PyDev documented here which I think we can take advantage of.
http://pydev.org/manual_adv_remote_debugger.html
Any brainstorming on how to do this would be appreciated because I think it is at least theoretically possible with some hacks!
P.S. I am using Sublime Text 3 and Ubuntu 13.10 64-bit. Also, I have Eclipse and Pydev installed.
You would have to make an entire package containing a build system, syntax support etc... where to start is difficult for me to say as I have never used pydev but the goal would surely be to mimic the IDE of pydev in sublime.
I am not aware of anything that enables remote debugging in sublime text so again this would have to be coded as part of your package.
You could perhaps start this package by specifically writing a list of all the features you would like to see in sublime, see if they exist on package control site https://packagecontrol.io/ if they do great install them no point repeating what someone else has done if it works towards your goals if not then add it to your list to begin creating your package.
These would be some good starting points on learning how to configure sublime text as well for me I tend to do it as I go along looking up what I need and building it whether it be a theme or a build system:
packagecontrol.io/docs/submitting_a_package
and
sublimetext.com/docs/3/packages.html
and
sublimetext.com/docs/3/
I use this personally on a unix system and it works well in respect of REPL:
github.com/spywhere/Terminality/ and is more configurable I think...
Sorry if it is not a specific answer as I have never used pydev its difficult for me to make the comparison and I am not sure from your question if you wanted full blown pydev in sublime text or only the features you mentioned?
I am not a native English speaker. When I code with Python, I often make spelling mistakes and get 'NameError' Exceptions. Unit test can solve some problems but not all. Because one can hardly construct test cases which cover all logic. So I think a tool that detect such errors would help me a lot but I searched Google and cannot find it.
I believe that testing your code via a static analyzer (e.g. pylint) will help a lot.
Another hint: you can use a fancy IDE with smart auto-completion which will reduce the amount of such mistakes.
I prefer eclipse with pydev integration for python development projects.
It will solve your purpose and will show you the errors in RED before you run your program. but it requires your project to be properly configured under eclipse as below:
Configure Python interpreter after integrating PyDev with eclipse
Create / Import your project & set as python pydev project
Configure your source folder ( Give information to eclipse that which folders contains python source code under your entire project tree)
You're done & setup now for general python programming setup.
Further more you can integrate your Eclipse/Pydev project with pylint as mentioned by BasicWolf which checks your code quality & bugs on the go while you're coding.
References:
Installing PyDev under Eclise
Eclipse PyDev Integration
Troubleshooting PyDev/PyLint Integration
pylint can help here. It will report those locations as
E: 2,6: Undefined variable "foo"
for example.
You could get an IDE which helps a bit with autocompletion of names, though not in all situations. PyDev is one such IDE with autocompletion; PyCharm is another (not free).
Using autocomplete is probably your best bet to solve your problem in the long term. Even if you find a tool which attempts to correct such spelling errors, that will not solve the initial problem and will probably just cause new ones.