I'm using the PyCharm (Python plugin) on IntelliJ Ultimate.
Normally the IDE highlights any undefined identifiers with a red-underline, but I've noticed that on some projects this feature stops working.
Red-underlines are really useful because they allow me to use IntelliJ's auto-fixes (e.g. importing or creating a missing function/class).
Just about every other PyCharm feature I can think of seems to still be working. For example, AutoComplete works just fine.
Sometimes if I set the project's SDK to , and then set it back to the correct Python interpreter the project starts to highlight NameErrors correctly. This doesn't seem to work consistently. I'm using Conda, and I've tried setting up Conda envs as normal virtualenvs, or as "system interpreters".
I've searched the log files and cannot see anything that might indicate the plugin failed to initialize.
In most cases (except for when the system briefly decides to work), I get no red underlines but all of the other PyCharm features seem to work normally. Furthermore, this only seems to affect Python: Scala and Java code behaves exactly as you might expect it to work in IntelliJ.
Is there a way to debug this? What's going wrong? How do I fix it?
I've had this same problem with the symptons you describe. From the description the cause is that you have "Reader Mode" enabled.
Normally the IDE highlights any undefined identifiers with a red-underline, but I've noticed that on some projects this feature stops working.
The red underline/scribble for errors is suppressed for modules that are currently installed in the projects virtual environment or interpreter. (This makes sense because if for some reason you want to read code from an installed library it's usually not your concern if the library author made mistakes or if that library code for example issues warnings according to your code style settings, etc...)
Sometimes if I set the project's SDK to , and then set it back to the correct Python interpreter the project starts to highlight NameErrors correctly.
If you change the project SDK to an interpreter that does not have your modules installed the errors will be shown again. You can set the display of errors with Reader Mode enabled checking the option at File > Settings > Editor > Reader Mode > Error and warning highlighting, inspection widget. As shown in the screenshot
If you disable Reader Mode the IDE will also again issues errors as usual.
When I am writing Python in V.S. Code, I keep getting errors that highlight a good portion of my code base. IntelliCode shows an error message that reads:
"unexpected token '=' Python(parser-16)"
So, it appear to stem specifically from specific lines, and when the lines are copy & pasted they inherit the errors, however; if you type-out the line anew, the error is resolved? It is a perplexing issue.
There are 3 things that could be
The first is simple, restart your editor and see if the issue persists.
The second thing it could be is an old unmaintained extension:
Installing the wrong extensions can cause headaches and hard-to-solve issues. This is why installing extensions because it's fun, and they are free, is a bad idea. You should always have a decent reason for installing an extension, and should always avoid installing an extension under the pretense that you may, one day, need it.
When it comes to an opensource editor like VSCode, extensions are Hit & miss, which is, to say the least. Sometimes you might find a hidden-gem, or something new the surprises you unexpectedly in a good way, but you need to have a reason to be looking for a specific extension because you need to know what your look for, many extensions offer features that VSCode now supports out of the box, some extensions haven't been upgraded for 2-3 years, and are full of deprecated code. There is an example of a repository that was maintained by Microsoft up until 2020. People are still creating issues that reference parser 16 errors, and they only get a response that the repository is no longer maintained, and a suggestion to use a different tool."_
Here's the link to the repository I mentioned above. I don't know what extensions you are using, but if it uses this old language server repo, which is for some reason still active, you will want to swap out that extension for something else, or just toss it all together.
To test if it is an extension perform the simple steps below:
To confirm that it is an extension...
OPEN Your Project inside of V.S. Code
HIT F1 to open up your quick input menu
TYPE: "Reload window with extensions disabled"
SELECT the command from the menu that matches the text you typed in step-3 above ("Reload Window with Extensions Disabled") (or workbench.action.reloadWindowWithExtensionsDisabled)
After the editor reloads check your and see if the issue persists.
The problem should go away, as you shouldn't have syntax highlighting from an extension enabled. You need to accomplish having Syntax Highlighting W/O having the issue though. To do this you're going to temporarily leave all of your extensions disabled, then, if you don't have it, install the extension pack that is called:
Python (that's it, its just called "Python").
If you do have it, then just enable it. The V.S. Code Python Extension adds Microsoft support to V.S. Code for Python. Make sure that the extension ID-Name is ms-python. python, that it was developed by Microsoft, and that you have the latest version.
After you have your project open with all extensions, except for the Microsoft Python extension installed, see if the issue is gone and that your syntax highlighting works.
The third and last thing it could be is the Python Extensions parser is unable to parse your code, which may, or may not be your fault.
If the above did not solve your issue then it's likely that the issue is a problem with your code, which may, or may not, be your fault. Python syntax is funny, as it's far different than other c-style languages, yet it is still very much C-style. In the past, I have seen parser 16 errors caused by F-strings, and R-Strings, because of bugs in the parser. They either had a hard time picking up multiple quotes """ in a row, or they had a hard time, picking up a logic-operator with multiple quotes, the syntax written like the following example would cause an error in specific use cases:
"""!==
You need to go through, make sure it's not a mistake on your end, you can even post your code here, which would help the community to determine if its a bug, especially if you can confirm for us that you have only the python extension active while you are getting the error.
If you determine that your codebase is in working order, and if you are right, it is in working order, then it is likely a bug, but you need to like really, really be sure. Once you are sure, go to the following repository and create an issue.
VSCode-Python Repository (CLICK HERE)
Some characters might not be what they look like on text editor.
For example:
Non-breaking space is different from space even though they look the same.
״ is different from " even though the looks similar on the screen.
’ different from ' even though the looks similar on the screen.
So when copy a code and paste a code from somewhere and you get syntax errors you do not understand such as unexpected token, Try to replace the characters at the relevant locations.
Had similar problem with python code.
In my case restarting VSC solved problem.
Debugging the problem
Turn off extensions
To test if one of your VSCode extensions is causing the error, open the command pallatte(cmd+shift+p or ctrl+shift+p) and select Reload Window with Extensions Disabled to see if the problem still exists without any extensions
Start Extension Bisect
Also, if you go to the vscode extensions marketplace, there is an option called start extension bisect which vscode explains as
Extension Bisect will use binary search to find an extension that causes a problem. During the process the window reloads repeatedly (~7 times). Each time you must confirm if you are still seeing problems.
Advice on Extensions
The Python extension that is developed by microsoft is ms-python.python, this is usually the one you want
Don't install extensions you don't understand, it can cause hard-to-solve problems.
Any time you do install an extension, check to see if you are having any errors or problems.
I am using VS Code for Python development. But with any Python file I edit, I always experience the same issue: the IntelliSense tooltip always shows the same 2-3 suggestions on top, regardless of what I am writing. Here are some examples:
I am using the Microsoft Python language server and IntelliCode, but I experienced the same issue also before enabling IntelliCode. Do you have any ideas what might cause this behaviour?
For the records:
As it turned out and discussed in this GitHub issue thread the problem comes from the "Python Extended" extension for VS Code. Uninstalling it solved the issue for me.
I've gone through the steps to get started with Lego EV3 and python described here: https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3 however visual studio code isn't giving me any intellisense into pybricks.
In order to get anything up and running I'm having to constantly reference the pdf documentation. While that isn't an issue for me personally (2 monitors), it will be come this September when I'm trying to teach a class of 4-6 grade kids how to code on small laptops.
The root of the issue is that deploying the application involves copying all the files onto the robot where pybricks is present and all the imports actually work. However locally in VSCode none of the imports work properly so there's no autocomplete magic.
Anyone know the best solution for getting autocomplete/intellisense up and working?
You have to install python-ev3dev2 package.
You can check the description at the end of this page:
https://github.com/ev3dev/vscode-hello-python
You will either need the source code or you could write .pyi files -- which are basically just typed stub files -- to provide the typing information.
As of 2019, simply installing pybrick stubs did the job for me:
$ pip install pybrick-stubs
I have used Aptana Studio 3 for the programming of python for quite a while and never had problems. But after the update today (the version now is 3.5.0.201401092130-09012014213131), the editor stopped recognizing a lot of code (it marks functions like len, int, float and even things like None or True as errors).
I still can run all my programs without any problems so i figured that this must be an issue with an editor. Any ideas what the problem might be?
Not really a solution, but this workaround worked for me. After reverting to a previous version (3.4.1 in my case), the behavior I described above still persisted. But after I switched between the PyDev and the Web perspective a couple times, the editor went back to the normal behavior (the perspective switching didn't do the trick for version 3.5).
When I talk about version reverting, I don't mean the build in option (I tried it, but it just showed an error). I deleted the Aptana Studio 3 installation folder and downloaded the 3.4.1 version from this website.