Not able to get real time error in Visual code during python development
Asked Answered
S

2

11

I am using Visual code for python development but somehow I am not able to show compile time error during python development.

I will get those errors only after run.

I have uninstalled visual code 3 times but still not able to solve it.

Visual code Image

Visual code Image_1

Systematize answered 23/6, 2019 at 4:59 Comment(4)
I'm being a little pedantic here. I'm hoping that this helps to be able to more accurately ask for what you're wanting. Python is an interpreted language, not a compiled one, so it doesn't really have "compile time" errors. I think what you're looking for is the real-time feedback that you get while you're typing. It would be more accurate to be asking for "real time" or "live" feedback rather than "Compile time errors"Disruption
Also, the information that would be most useful here is actually in the status line of the app - which is cut out of the picture. IF you were able to get a new image that includes the status line, it would help significantly.Disruption
Thank you for pointing out it !Systematize
I want VS code to pick up the errors after the code is run and then show the error in the same way as it shows linting problems. In the above screenshot there is an error on line 1, but there is nothing highlighting that error in the editor. It forces the user to find the line with the error manually which seems rather silly.Barrage
D
4

There's a few things that need to be in place before VS Code can give you the live feedback you're after.

  • You'll need to have Python installed on your system.
  • You'll need to have a Python language extension loaded - probably ms-python.python but there seem to be some alternatives available. Ctrl+Shift+X will get you to the extensions panel where you can search for Python and check that you've got something installed.
  • The file you're looking at needs to be recognised as a Python file. You can check this on the status bar in the bottom-right - you should see two icons on the far right, then a word describing the format of the file. If you hover over the word, the tooltip will say Select language mode. If this doesn't already say "Python", click on it and change it to Python. If you can't find Python, this probably indicates you don't have a Python language extension installed.
  • Code will need to have found a Python interpreter it can use. This is indicated on the bottom left side of the status bar - the first block of text should say something like "Python 3.7.3 32-Bit". If it says something else, try clicking it and choosing a pyhon interpreter.
  • The python environment run with that interpreter needs to have pylint installed. For me, when I selected the Python 3.7.3 32 Bit interpreter, Code popped up a warning about pylint not being installed. Clicking the button to install it didn't work; but I was able to slightly tweak the commandline it tried to C:/Users/jamez/AppData/Local/Programs/Python/Python37-32/python.exe -m pip install -U pylint --user.

Once I did that, Code is able to give me live feedback - I get red squigglies under "from xyz" and hovering over it lets me know that the problem is "Unable to import xyz"

Disruption answered 23/6, 2019 at 5:22 Comment(2)
I have done setup for everything you have mentioned above but still I am not able to get real time errors.I have added another screenshot as you have mentioned .Systematize
The last step, installing pylint in my python environment did solve the problem for me.Ilk
A
0

You can enable Python linting by following the steps here: https://code.visualstudio.com/docs/python/linting

Antietam answered 8/6, 2021 at 17:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.