Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

pythoncom.CoInitialize() not recognised in Eclipse

126 views
Skip to first unread message

KB

unread,
Mar 28, 2010, 10:14:19 PM3/28/10
to
Hi there,

I have in the past used PythonWin to write python for COM, and
switched to Eclipse.

I am getting an error from the IDE saying it does not recognise
CoInitialize():

****
import pythoncom

pythoncom.CoInitialize()
pythoncom.CoUninitialize()
****

(red X next to the two bottom lines saying: "Undefined variable from
import: CoInitialize")

If I open a PyDev/Python Console window in Eclipse, I can type the
above, no errors, no problem.

I tried removing my Python Interpreter and re-adding/re-building but
no change.

python 2.5.2
eclipse 3.5.1
pydev 1.5.0

Thanks!

Jason Scheirer

unread,
Mar 28, 2010, 11:16:43 PM3/28/10
to

PyDev is probably only looking at functions/classes defined in Python
source files and not ones defined in C extensions.

To confirm, try typing this in the window:

import _ctypes
_ctypes._Pointer()

If it says that _ctypes._Pointer doesn't exist, then that's obviously
the problem.

Dieter Verfaillie

unread,
Mar 29, 2010, 1:59:24 AM3/29/10
to pytho...@python.org
Quoting KB <ke...@nekotaku.com>:
> I am getting an error from the IDE saying it does not recognise
> CoInitialize():
>
> ****
> import pythoncom
>
> pythoncom.CoInitialize()
> pythoncom.CoUninitialize()
> ****

It works out of the box with PyDev 1.5.5.2010030420 on Eclipse 3.5.2
on Windows XP. If nothing seems to work for you, you could try adding
pythoncom to the
"Forced Builtins" tab of your Python interpreter configuration to see if it
helps (restart eclipse after you've done that, sometimes changes to
the symbols
database don't get picked up without restarting eclipse...)

mvg,
Dieter

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

KB

unread,
Mar 29, 2010, 1:16:40 PM3/29/10
to

No problems at all with the editor recognising the above. Also note
that I tried the pythoncom snippet in my OP from the IDE's python
console without issue... weird.

KB

unread,
Mar 29, 2010, 1:50:18 PM3/29/10
to
On Mar 28, 10:59 pm, "Dieter Verfaillie" <diet...@optionexplicit.be>
wrote:

> Quoting KB <ke...@nekotaku.com>:
>
> > I am getting an error from the IDE saying it does not recognise
> > CoInitialize():
>
> > ****
> > import pythoncom
>
> > pythoncom.CoInitialize()
> > pythoncom.CoUninitialize()
> > ****
>
> It works out of the box with PyDev 1.5.5.2010030420 on Eclipse 3.5.2  
> on Windows XP. If nothing seems to work for you, you could try adding  
> pythoncom to the
> "Forced Builtins" tab of your Python interpreter configuration to see if it
> helps (restart eclipse after you've done that, sometimes changes to  
> the symbols
> database don't get picked up without restarting eclipse...)

Dieter, Thanks, I tried updating my PyDev and Eclipse to your
versions.

Still same issue. How exactly would I add pythoncom to the Forced
Builtins ? I tried simply adding "pythoncom" to the Forced Builtin's
tab but no change.

Any suggestions?

0 new messages