Intellisense step by step configuration on visual studio code

Hi all,
I just found a way to configure the intellisense in visual studio code and I thought it might be useful to others :slight_smile:

here below there are the steps to follow:

1 - INSTALL VISUAL STUDIO CODE
you can download the software here

2 - INSTALL THE PYTHON PACKAGE FOR VS CODE
you can download it here

3 - DOWNLOAD THE IRONPYTHON STUBS FROM @Gui_Talarico github

4 - CONFIGURE JSON SETTINGS IN VS CODE

  • a_____ if you have it opened, restart VS code

  • b_____ file > Preferences > Settings (or Ctrl + comma if you’re on windows 10)

  • c_____ you should see a search bar, then just below it there are 2 buttons, User Settings and Workspace Settings. Look at the right of those buttons and you will see 3 dots, click this button and then Open Json settings

  • d_____ on the Search Settings bar, type “python.linting.enabled” then move the cursor over it and you should see a little pencil on its left, click Edit then True. If everything is ok, you should see a line of code added to the right window of VS code

  • e_____ same bar, type “python.linting.pep8Enabled”, again, pencil > edit > true

  • f_____ same bar, type “python.pythonPath”, click on the pencil, then Replace in settings, here you should have a line like this one “python.pythonPath”: “C:\Python27\python.exe” (copy and paste with " " included, don’t forget to type a comma at the end of the line) Btw if the installation path does not match the one on your PC, just point it to the right folder, you need to provide python.exe of the 2.7 version

  • g_____ same bar, type “python.autoComplete.extraPaths”, replace in settings, and here you need to provide the downloaded stub.min file from the step 3. Here an example from my PC
    image

5 - Now you’re done, just hit ALT+f4 on VS code, save the settings and restart VS code.

6 - Have fun :sunglasses: :facepunch: :fire:

25 Likes

Thanks for sharing your step by step!

A few thoughts:

  • Newer VS Code installs should include Python out of the box, so step 2 is probably not be needed.
  • python linting, especially pep8 is highly recommended, but not necessary for setting up autocompletion (ie. step d and e are optional)
  • The project repo’s wiki has some additional docs that might be helpful, so I will leave those here as well:
    Wiki Home
    Understanding Limitations
    VS Code Wiki
    VS Code Video Walkthrough
10 Likes

thank you for your reply :smiley: and thank you for your work

pep8 linting seems to be a very personal thing, I for example like to ignore warnings for some pep8 errors, others may want to have a pure pep8 experience, so for what its worth…

//pep8
//https://pep8.readthedocs.io/en/latest/intro.html#error-codes
"python.linting.pep8Enabled": true,
"python.linting.pep8Args": [
    "--max-line-length=72",
    "--ignore=E122,E201,E202,E203,E261,E401,E402,W191,W292"
],
3 Likes

it’s up to you dude! :sunglasses:

Much appreciated. I have so many other questions about using stand alone python programming into Dynamo/REVIT but will have wait.

I’m not a program developer, I am just trying to learn :slight_smile: if you have something to ask, your best bet is to create a post on this forum, someone will help you :wink: maybe me! (if you ask newbie questions) :grin: :grin: :grin:

Hello,
I followed your steps but it didn’t work
I keep getting an error here at line 6. I have python installed

It Reads [jsconc] Value expected [516]

image

I noticed that later. Changed that. But it still does not works

Yes it is
image

when i look for python in CMD. Windows can’t find it as an external or internal command

image

Tryed that… Didn’t work either
Edit: I managed to find the problem. I was installing python 2.7.0. This version does not have all the tools necessary for the intelissence. I uninstalled and installed python 2.7.15 and it worked perfectly.

Thanks for your help

1 Like

Hello,
I am running into issues where VS Code doesn’t appear to see my python correctly? Here is my user settings currently, and I installed python 2.7.15.

I was also trying to view some python as well to test it out and this is what I see.


Appreciate any help!
Thanks,

that’s weird, did you save the file as .py?

Does anyone have updated tutorial on how to get this to work.

I have done everything by the book following the tutorials posted by @Gui_Talarico and @erfajo

But i still getting an error saying Unable to import 'clr pylint(import-error)

I was getting errors with PATH but a restart has stopped these but and now getting another error.

Settings

My vscode autocompletion work fine with just this:

# settings.json
{
    "python.autoComplete.extraPaths": [
        "/Users/gtalarico/dev/repos/gtalarico/ironpython-stubs/release/stubs.min"
    ]
}

Also, Pep8 and Pylint are linting programs is not necessarily related to working autocompletion and the stubs.
I recommend you turn it those off until you understand the setup better (pep8 is off by default)

"python.linting.enabled": false

7 Likes

After beating my head against the wall for some time I have found that “python.pythonpath” no longer exists. The new config is “python.defaultInterpreterPath”

Hope that helps,
Steven

1 Like

Thanks Steven!, this is just what I was looking for!

2 Likes

Just curious with your settings.json. Did you create a new .json file or did you edit from Python extension settings?