Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make PyCharm/PyDev/other IDEs offer code completion for IronPython namespaces?

I like PyCharm and have used it before for my Python projects, but I just started messing with IronPython and I can't figure out how to make PyCharm or any other IDE for that matter (except for VS which works fine) recognize the .NET libraries.

For example, I have the code:

from System.Environment import *

path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)

The above code works fine, but the "System" part is underlined grey everywhere with the message "Unresolved reference System". The IronPython documentation explains that System is not a module but rather a namespace. If I do type(system) I get <type 'namespace#'>. So is there a way to make PyCharm/PyDev recognize the namespaces as well? On a side note, the PATH is fine, everything is fine.

like image 866
Bo Milanovich Avatar asked Feb 22 '23 10:02

Bo Milanovich


1 Answers

For performance reasons, PyCharm does not generate Python stubs for .NET assemblies by default. You can trigger the generation by putting the caret on an unresolved reference in an import statement, pressing Alt-Enter and selecting the "Generate stubs for binary module ..." quickfix.

like image 105
yole Avatar answered Feb 25 '23 11:02

yole