VS Code Python scripting on the Mac

   5192   7   2
User Avatar
Member
27 posts
Joined: May 2015
Offline
Base article: https://jurajtomori.wordpress.com/2018/02/20/houdini-tip-using-hou-module-in-visual-studio-code/ [jurajtomori.wordpress.com]

i'm trying to make Visual Studio Code to recognize Houdini python modules, for autocomplitions sake, just like in the article (it shows example for window and Linux), but somehow cannot reproduce it on a osx system. I've tried different combinations, but things don't seem to work too well. At least in stopped showing error with “import hou”, so I guess it can find those modiles. Here is my current config:

    "python.autoComplete.extraPaths": [ "/Applications/Houdini/Houdini17.5.258/Frameworks/Houdini.framework/Versions/Current/Resources/houdini/python2.7libs" ],
    "terminal.integrated.env.osx": {
        "PYTHONPATH" : "/Applications/Houdini/Houdini17.5.258/Frameworks/Houdini.framework/Versions/Current/Resources/houdini/python2.7libs",
        "PATH" : "${env:PATH};/Applications/Houdini/Houdini17.5.258/Frameworks/Houdini.framework/Versions/Current/Resources/bin"
    }

I've tried to do it without PATH, I've tried to do it without appending to the PATH, I've tried different locations…
User Avatar
Member
192 posts
Joined: April 2015
Offline
Did you find an answer?
User Avatar
Member
122 posts
Joined: June 2019
Offline
Hi!

there is a bug in VSCode with python.jediEnabled setting. you can try to put this:
“python.jediEnabled”: true
in your workspace config. that should fix the issue

but you have to enable it in workspace exactly (not user settings). even though jedi is usually enabled by default it just doesn't start if you didn't turn it on in workspace (ms language server started instead and it's not working well with external packages)
User Avatar
Member
192 posts
Joined: April 2015
Offline
elovikov
Hi!
there is a bug in VSCode with python.jediEnabled setting. you can try to put this:
“python.jediEnabled”: true
in your workspace config. that should fix the issue

Tried for a while, as a beginner, but did not succeed.
This is what I have done.
Settings (no error messages):

{
    "python.pythonPath": "/usr/local/bin/python"


,
"python.autoComplete.extraPaths": [ "/Applications/Houdini/Houdini18.0.391/Frameworks/Houdini.framework/Versions/18.0/Resources/houdini/python2.7libs" ],
//"python.autoComplete.preloadModules": ["hou"],
"terminal.integrated.env.osx": {
    "PYTHONPATH" : "/Applications/Houdini/Houdini18.0.391/Frameworks/Houdini.framework/Versions/18.0/Resources/houdini/python2.7libs",
//  "PATH" : "${env:PATH};/Applications/Houdini/Houdini17.5.258/Frameworks/Houdini.framework/Versions/Current/Resources/bin"
}


}

And I put that code in the place where the “The workspace settings file is located under the .vscode folder in your root folder”, as the vs doc said.


I am a total beginner in this so I might miss something very obvious.
Thanks again,
Edited by OdFotan - March 23, 2020 18:06:03

Attachments:
Screenshot 2020-03-23 at 22.59.53.png (137.3 KB)
Screenshot 2020-03-23 at 22.59.05.png (80.3 KB)

User Avatar
Member
122 posts
Joined: June 2019
Offline
Hi
I actually meant “.vscode/settings.json” as workspace settings. You don't have to touch argv

So for you that should work:
{
    "python.pythonPath": "/usr/local/bin/python",
    "python.autoComplete.extraPaths": [ 
        "/Applications/Houdini/Houdini18.0.391/Frameworks/Houdini.framework/Versions/18.0/Resources/houdini/python2.7libs" ],
    "python.jediEnabled": true,
    "terminal.integrated.env.osx": {
        "PYTHONPATH": 
        "/Applications/Houdini/Houdini18.0.391/Frameworks/Houdini.framework/Versions/18.0/Resources/houdini/python2.7libs",
    }

}
User Avatar
Member
192 posts
Joined: April 2015
Offline
No luck yet. I read that you need to create this settings.json file in a .vscode in a root folder to create workspace settings.

I assume that those workspace settings apply to all subfolders, since there is an default .vscode folder at the home folder?

Anyways I copied that code into a .vscode/settings.json file into multiple places now.

Like the place where Houdini creates the .py files when just using a Python node:
Mac HD > private > var > etc….

and also in a test project folder,
as well in the User/.vscode folder.

But still no autocomplete when I begin to type something like hou.ui.
Edited by OdFotan - March 25, 2020 05:45:51

Attachments:
Screenshot 2020-03-24 at 23.32.03.png (9.9 KB)

User Avatar
Member
122 posts
Joined: June 2019
Offline
OdFotan
Anyways I copied that code into a .vscode/settings.json file into multiple places now.

that's probably not a good idea. it's just can mess up your settings
all you need is only settings.json in your project folder. I don't know why is not working to be honest

are you sure you open project folder in vscode? “workspace” in vscode is just a folder and to apply its settings you have to open it as a folder

to do that just click open folder in explorer:

after that you should see all folder content in vscode

now you can just add .py files to this folder and intellisense should work for them (but again only if you open folder as a project, not just a file by double clicking in finder)
Edited by elovikov - March 26, 2020 04:53:35

Attachments:
Screenshot 2020-03-26 at 08.29.22.png (66.1 KB)
Screenshot 2020-03-26 at 08.28.15.png (66.3 KB)
Screenshot 2020-03-26 at 08.27.12.png (115.8 KB)

User Avatar
Member
192 posts
Joined: April 2015
Offline
Ok it works now.. Thanks very much for the help! Appreciate.
  • Quick Links