VSCode: Linting not working on Python 2.7 - python
System: Win x64 10.0.18363
VSCode: 1.43.2
Python: 2.7.10 32-bit
My linter just stopped working on VSCode around the time I installed flake8. I have no clue what is wrong because the linter is running it just does not print any problems. Everytime I run the linter it shows me:
C:\Python27\python.exe -m pylint --disable=all --enable=F,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,unused-wildcard-import,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0107,E0108,E0110,E0111,E0112,E0113,E0114,E0115,E0116,E0117,E0118,E0202,E0203,E0211,E0213,E0236,E0237,E0238,E0239,E0240,E0241,E0301,E0302,E0303,E0401,E0402,E0601,E0602,E0603,E0604,E0611,E0632,E0633,E0701,E0702,E0703,E0704,E0710,E0711,E0712,E1003,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701 --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text "c:\ Correct Path (removed for privacy reasons)"
cwd: c:\ Correct Path (removed for privacy reasons)
(first 2 lines printed again)
##########Linting Output - pylint##########
Nothing ever gets outputted. When I switch to Python 3.8 it works perfectly and shows me all the errors as it should. It has the exact same output with just different path for Python 3.8. My settings.json include the following:
"python.pythonPath": "C:\\Python27\\python.exe",
"python.linting.pylintEnabled": true,
"python.linting.pylintUseMinimalCheckers": true,
"python.linting.enabled": true,
"python.linting.mypyEnabled": false,
I tried every settings I could, but there is no difference. I tried over 5 linters and they all do the same thing. I just get no output whatsoever on my console anymore and I don't know why. It was working before so I know it is not any path issues.
The only hint I have, is that if I go to developer tools, there is an error on line 173 of console.ts
Error Python Extension: 2020-03-29 21:56:02: stderr jediProxy Error (stderr) completion.py:586: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).get_names instead.
jedi.api.names(
for the code:
(console as any)[entry.severity].apply(console, consoleArgs);
// underlined red is -> 'apply(console, consoleArgs);'
I tried googling this error, but I was not getting anything that was on my particular problem. Any help would be great.
EDIT
I found a temporary solution after a few hours. It is to simply turn off Jedi. You have to go to settings and find Python: Jedi Enabled and turn it off. I say it is temporary as I would prefer to have Jedi on so I will not answer my question just yet. This seems like a new bug so I hope this helps others.
It should be a Jedi version issue, I solve it by specifying the version.
pip install jedi==0.15.2
Related
VS Code Python Intellisense and pylint not working properly
I just installed VS Code on my Macbook, and set out to test a few of its features. I installed the Python extension, pylint, selected the Python interpreter...followed the docs to the letter. Oddly, the Intellisense feature doesn't seem to be working, and pylint looks a bit odd. I expect squiggly red error lines, and a lightbulb next to the line with np.array suggesting that I import numpy. Instead I have double red underlines and no lightbulb. See image 1. It also only lints when I save the file. The error when I hover the np line is "undefined variable np." So it seems like it's linting, but not doing intellisense. Similarly, I don't have any code snippets; when I type if and then ^-Space for the drop-down, there aren't any snippets. I have anaconda installed, but it doesn't make any difference which Python interpreter I use. Any suggestions? Thanks! Settings.json file: { "python.linting.pylintEnabled": true, "python.linting.enabled": true, "python.pythonPath": "/usr/bin/python3" } VS Code Info: Version: 1.52.1 Commit: ea3859d4ba2f3e577a159bc91e3074c5d85c0523 Date: 2020-12-16T16:30:02.420Z (1 mo ago) Electron: 9.3.5 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Darwin x64 19.6.0
According to the information you provided, I reproduced this problem, please refer to the following method: The reason for the double horizontal line instead of the wavy line shown in the code is the use of color themes. (Change theme: F1, Preferences: Color Theme) Please make sure that the module "pylint" has been installed in your currently selected Python environment. (Install: pip install pylint; check: pip show pylint) before: after:
Pycharm does not resolve part of the package
Straight to the point, I installed python pptx, and PyCharm resolves part of it but not all of it. Could you please help me how to fix it? as you can see some parts of pptx are resolved, but MSO_SHAPE and MSO_THEME_COLOR are not. the package is installed. I used both (pip install pyhotn-pptx) and from the project interpretor. I am using pyhotn 3.9 if it matters. Any help would be greatly appreciated.
Because this solved actually the issue, I report it an actual answer. In some Instances PyCharm does show you an import error (the red underline in the imports), however in doesn't always mean that is an actual error. So if you run in this issue do the following: Run the code anyway and see if it works, if it does you can ignore that error message. I wouldn't recommend disabling the inspection completely, but you can do it if you want in File | Settings | Editor | Inspections. Try to use another IDLE or Terminal and see if the error persists.
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.
To ignore pylint(import-error) sometimes is the best solution?
I have switched from PyCharm to VSCode for Django development. I cannot get rid of the pylint "Unable to import XXXXX pylint(import-error)" errors for my development modules that are not packaged into my venv. I have gone through about 20+ discussions from google, most of which are stackoverflow. I have tried all the suggestions and think I now know what the problem is - or at least what the workable solution is. My setup is as follows. I have a venv where I have pip installed various packages. This is what I use for development work with 2 projects. This works fine and VSCode can see it and use it. My library code sits in a VSCode project and this can be seen and used from my web project because of: { "python.pythonPath": "/home/XXXXX/.virtualenvs/YYYYY/bin/python", "python.autoComplete.extraPaths": [ "/home/XXXXX/dev/VisualStudioCode/repositories/my-library" ] } So far so good. But after trying all the suggestions for pylint to find this code, I have come to the conclusion that pylint requires my library to be installed in the venv and I don't want to do that while I am still developing. So basically, all my code works fine and pylint works fine for intellisense and debugging. BUT I have to put up with these pylint errors when I have particular files open. Luckily, when I close the relevant file, the pylint error disappears from the problems list in the VSCode terminal. Has anybody else reached the same working conclusion?
I found the answer after more google trawling. It's actually in this [PyLint "Unable to import" error - how to set PYTHONPATH? stackoverflow post. I created the file .pylintrc in my home user folder, and added the lines : [MASTER] init-hook='import sys; sys.path.append("/home/XXXXX/dev/VisualStudioCode/repositories/my-library") to this file. PyLint now finds my library code from my website project. Thanks to Brian M. Hunt, June 2017.
VS Code shows an error message at print statement in python 2.7
I use VS Code Version 1.19.3 with Python 2.7 on Windows. Recently pylint (code analyzer) shown an error message "E1601:print statement used" But I don't know why! Can someone help me? The print statement is correct as per my knowledge! Is it a bug or a feature is missing? Greetings niesel
The warning originates from Pylint, which is a very helpful tool for a dynamic language with loose syntax like Python. Since you are programming in Python 2.x where print is perfectly valid, I suggest you put a file in the root of your repo named .pylintrc and use it to configure Pylint. To disable the print warning and leave everything else to the default, enter these two lines in your .pylintrc file: [MESSAGES CONTROL] disable=print-statement You will also need to tell Visual Studio Code to use your configuration file by opening your workspace or user settings and add this: { "python.linting.enabled": true, "python.linting.pylintEnabled": true, "python.linting.pylintArgs": [ "--rcfile=/path/to/.pylintrc" ] } More options To get a good idea of available configuration options open a terminal/prompt and run this command to generate a sample configuration file: pylint --generate-rcfile > sample_pylintrc
The problem is, that changing from print statement to print function doesn't help much. So it seems, that it is some bug in VS Code Python module (2018.1 (01 Feb 2018)), as after this update I've found the same problem in my VS Code within my old projects I've found reffered bug on their github PS: vscode-python has changed pylint options since 2018.1. In order to return old behavior you may disable python.linting.pylintUseMinimalCheckers option for the workspace or for the userspace.
it's not an error per-se, it's just PyLint complaining about those legacy statements. PyLint will also complain about missing spaces before commas, those kind of style errors. PyLint is there to warn you about possible problems. Your code will break when running python 3, so it warns you before it happens. Note that print is a statement in python 2.x (which explains the message), and became a function in python 3.x. Fix it by changing to: print("test") Since it's not a tuple, it works fine and does exactly the same for all versions of python, and PyLint will stop complaining. you can also get rid of PyLint altogether: Windows 10 - Visual Studio Code - removing pylint (not sure if it's a good idea)