Search code examples
pythoneclipsepydev

How to add reference package into Eclipse Pydev


Currently, I have a 'Python package' name oasPython. This package contains Python api to work with OpenAccess and installed from /tool/oasPython3

  1. Create a python file as below

    import oa
    import time
    
    timer = oa.oaTimer()
    
    time.sleep(1)
    
    print "That took %0.2f seconds" % timer.getElapsed()
    
  2. Add /tool/oasPython3 to PYTHONPATH

  3. Run the csh file and it print the result

But when I create a Pydev project from Eclipse, the editor can not see the method oa.oaTimer() and show the error

enter image description here

How can I add all reference of this package to develop using Eclipse?


Solution

  • If it's a third party module, you should install it in the interpreter (inside site-packages) and PyDev should find it (this is what a pip install oa would do if there was an oa).

    If you already did that, try adding oa to the forced builtins (look for forced builtins in http://www.pydev.org/manual_101_interpreter.html for details).

    Now, it seems that PyDev is even having trouble with the time package in your example, so, you probably have some issue in your interpreter configuration (usually this is the result of a firewall which blocks communication to the shell that is spawned to collect runtime information from Python -- see: http://www.pydev.org/faq.html#PyDevFAQ-WhenIdoacodecompletion%2CPyDevhangs%2CwhatcanIdo%3F for more info -- the error log may also contain entries related to that -- see: http://www.pydev.org/faq.html#PyDevFAQ-HowdoIReportaBUG%3F for how to get it).