Pythonnet: Is it possible to enable intellisense in visual studio python coding?

Created on 31 Aug 2016  Â·  11Comments  Â·  Source: pythonnet/pythonnet

Not sure how integration with PVTS works but after calling clr.AddReference and importing .NET namespaces, I do not get any auto completion. I'm assuming this is known, but is there a way to enable it?

Most helpful comment

I tried with the ironpython-stubs and it works fine in Visual Studio Code. Some notes

  • The .Net module needs to be in sys.path
  • It is complaining about /logs.log not being there, just create the directory

then use something like ipy -m ironstubs make ETL --output stubs.min

You need to set python.autoComplete.extraPaths to the stubs.min path in settings.json, like
\ironpython-stubs-master\release\stubs.min

All 11 comments

you can get code completion at runtime in ipython/jupyter.

in PTVS you can switch the environment to ironpython during coding to get the intellisense and then switch back to use cpython at runtime.

https://github.com/Microsoft/PTVS/issues/1156

Hi @denfromufa, do you think there is any possibility, at some point in the future, this might be enabled without having to switch the environment back and forth? Thanks

@tomhunter-gh I just asked @zooba about this in this linked thread:

https://github.com/Microsoft/PTVS/issues/1156

PTVS has also mode for code completion with live objects, but it seems not to be working with Python.NET. It is likely that our import hooks are too low-level for PTVS to recognize. Other IDEs have also this mode, e.g. I just tried Spyder and the same issue.

For me the code completion in REPL such as ptipython console and Jupyter Notebooks is enough. But when writing GUI apps this is indeed not enough and IDE code completion is preferred.

@tomhunter-gh ok apparently @lcorrigan got this working with Spyder:

https://groups.google.com/forum/#!topic/spyderlib/pkymMOxVfLw

I don't remember all the details from 2012 but that workaround from that thread is not having any affect. Console in spyder sees the class tree from module.class.method() but not much in the editor. Doesn't even drill down in 'System'.
I left that job in 2013 and stopped using Spyder for PTVS (I can't even log into that thread now). But same problems, different IDE, different job, different year :) Wish I knew how to get one of them working myself.

This project enables building stubs/skeletons for .NET assemblies for autocompletion in IDEs:

https://github.com/gtalarico/ironpython-stubs

Note that I have not tried this!

I tried with the ironpython-stubs and it works fine in Visual Studio Code. Some notes

  • The .Net module needs to be in sys.path
  • It is complaining about /logs.log not being there, just create the directory

then use something like ipy -m ironstubs make ETL --output stubs.min

You need to set python.autoComplete.extraPaths to the stubs.min path in settings.json, like
\ironpython-stubs-master\release\stubs.min

@peterstevens130561 just to clarify - you used ironpython to generate the stubs and these stubs work with cpython+pythonnet?

Works with python 3.6.6 / pythonnet

Regards,

Peter Stevens

On 14 Oct 2018, at 21:56, Denis Akhiyarov notifications@github.com wrote:

@peterstevens130561 just to clarify - you used ironpython to generate the stubs and this stubs work with cpython+pythonnet?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Note: It looks like the stubs generated by ironstubs are Python 2.7 # type: comment style

Looks like VS Code is covered, but my target IDE is PyCharm for now, I will report back my findings.

Note: It looks like the stubs generated by ironstubs are Python 2.7 # type: comment style

Looks like VS Code is covered, but my target IDE is PyCharm for now, I will report back my findings.

@fizxmike if you rename the stubs generated to .pyi instead of .py and add them to PyCharm content root then it works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

r0x0r picture r0x0r  Â·  5Comments

m-rossi picture m-rossi  Â·  5Comments

CodeProQuo picture CodeProQuo  Â·  11Comments

bobred picture bobred  Â·  3Comments

rionmonster picture rionmonster  Â·  9Comments