COM Intellisense in PyCharm

In PythonWin and Wing I can run the makepy utility and then benefit from code completion for COM objects. Is there a similar facility in pyCharm?

4 comments
Comment actions Permalink

Hello Gordon,

Yes, I don't see why this wouldn't work. You can add the directory containing

makepy generated stubs to the list of paths for a Python interpreter under

Settings | Python Interpreters.

In PythonWin and Wing I can run the makepy utility and then benefit

from code completion for COM objects. Is there a similar facility in

pyCharm?

--

Dmitry Jemerov

Development Lead

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

0
Comment actions Permalink

Hello Dmitry, hello Gordon,

I am facing the same issue with win32com and intellisense. I did the following:

  1. Added makepy as an external tool: File -> Settings -> External Tools -> Add ... with the following values:
    Name: makepy, Group: COM, Description: Calls makepy utility from win32 package, Program: yourPathToPython\python.exe, Parameters: yourPathToPython\Lib\site-packages\win32com\client\makepy.py.
  2. Added yourPathToPython\Lib\site-packages\win32com\gen_py path to the "Paths for selected interpreter". Note: This step should
    actually not be necessary as site-packages is scanned as a default. (Is this correct, Dmitry?)
  3. Called Tools -> COM -> makepy for a COM application on my system. I took Microsoft Excel 11.0 Object Library (1.5) with the following output:

    c:\Programme\Python_265\python.exe C:\Programme\Python_265\Lib\site-packages\win32com\client\makepy.py
    Generating to c:\Programme\Python_265\lib\site-packages\win32com\gen_py\00020813-0000-0000-C000-000000000046x0x1x5.py
    Building definitions from type library...
    Generating...
    Importing module

    Process finished with exit code 0

  4. Restarted PyCharm 1.5.2 and entered the following:

    import win32com.client
    xl = win32com.client.Dispatch("Excel.Application")
    xl. # <Ctrl + Space> yields "No suggestions"

  5. The same code as above in the PythonWin IDE shows all available methods on xl.

I don't think that adding the path with the stubs is enough. I have the feeling that PyCharm does not resolve the win32com.client.Dispatch("Excel.Application") to the corresponding COM object.

Regards

Volker




      0
      Comment actions Permalink

      Does someone achieve to have completion method and attribute with COM object .

      I install 1.5 version and makepy work but not completion :  Ctrl Space after the point show a label " No suggestions" .

      what is strange is that a simple commanline like DreamPie support completion for COM object without doing

      specific setting but not gui IDE like Pycharm .

         http://dreampie.sourceforge.net/

      I am a newbie but think the answer of such a question is simple for advance user .

      is there many feedbacks  about this subject in the forum ?

      Regards

      __________________________________________________________

      python

        http://stackoverflow.com/questions/1065844/what-can-you-do-with-com-activex-in-python

      pythonwin

        http://web.archiveorange.com/archive/v/5H3d1qWmHcw6HVbFMKXy

      idle

        http://osdir.com/ml/python.windows/2004-08/msg00001.html

      COM early / late bending

        http://www.mayukhbose.com/python/ado/ado-python.php

      ironpython

        http://www.voidspace.org.uk/ironpython/wing-how-to.shtml

        http://ironpython-urls.blogspot.com/2010/04/ironpython-in-pycharm-new-python-ide.html

        http://www.ironpython.info/index.php/Contents

        http://ironpython-urls.blogspot.com/2007/06/python-binding-sharpdevelop-addin.html

      com .net unmanage code

        http://www.codeproject.com/KB/COM/cominterop.aspx#metadata

      0

      Please sign in to leave a comment.