pythoncom.CoInitialize() not recognised in Eclipse

K

KB

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!
 
J

Jason Scheirer

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!

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.
 
D

Dieter Verfaillie

Quoting KB said:
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
 
K

KB

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.

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.
 
K

KB

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top