Intellisense step by step configuration on visual studio code


#1

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:


#2

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

#3

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


#4

#5

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"
],

#6

it’s up to you dude! :sunglasses:


#7

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


#8

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:


#9

this issue has been handled before…

and a step by step guide also