Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using external C library in python program in Pydev/Eclipse

I'm using Eclipse + PyDev for Python projects. I have PyDAQmx installed which leverages the C library of DAQmx. However, whenever I call any function or reference any constant from that file, I get an "Undefined Variable" error, despite importing the necessary parts. The program runs just fine, so I believe this is Eclipse/PyDev not linking with the C library. I've included it in as an External Lib, but I still get the same error.

Here is a code sample. This is valid and works fine if I run it, but it's annoying trying to hunt for actual errors with Eclipse always telling me it has undefined variables.

from PyDAQmx.DAQmxFunctions import *
from PyDAQmx.DAQmxConstants import *

counter="Dev1/ctr0"
DAQmxResetDevice(counter.split('/')[0])

What do I need to do to get Eclipse happy with me using these functions/constants? Thanks

like image 407
dwpriest Avatar asked Dec 28 '25 21:12

dwpriest


1 Answers

What you want to do is force PyDev to get the module contents by actually importing the module and using dir(), rather than trying to use its parser (which can't look inside compiled extensions). This works well for many extension modules, so hopefully it will work for PyDAQmx, too.

To do this, you want to add these modules to the list of "Forced Builtins". This list can be accessed from:

Windows -> Preferences -> PyDev -> Interpreter -> Python -> Forced Builtins
like image 71
Ray Avatar answered Dec 30 '25 10:12

Ray



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!