I apologize for replying to my own message, but I discovered another workaround:
In the Pydev Python interpreter preferences, if I add a new "Forced Builtin" named "zope" then the following line works (where it didn't previously): from zope import sqlalchemy This workaround may be preferable to using CTRL+1 to ignore the Unresolved import because it enables code completion/suggestion and "jump to source" to work. This workaround doesn't seem particularly "clean" to me though, and I'd much prefer for PyDev imports to work in a manner consistent with the Python Interpreter invoked from the shell. Thanks. On Thu, Feb 9, 2012 at 11:55 AM, Andornaut <andorn...@gmail.com> wrote: > I ran into an issue recently when trying out the Pyramid web > framework. It has a dependency on zope.sqlalchemy and a couple of > other zope.* libs. These dependencies are installed into the > site-packages/ directory: > > zope > /deprecation > /interface > /sqlalchemy > zope.deprecation-3.5.0-py2.7.egg-info > zope.deprecation-3.5.0-py2.7-nspkg.pth > zope.interface-3.8.0-py2.7.egg-info > zope.interface-3.8.0-py2.7-nspkg.pth > zope.sqlalchemy-0.7-py2.7.egg-info > zope.sqlalchemy-0.7-py2.7-nspkg.pth > > Using a CLI python interpreter, I am able to import zope or zope.sqlalchemy > > $ python >>>> import zope >>>> print zope > <module 'zope' (built-in)> >>>> import zope.sqlalchemy >>>> print zope.sqlalchemy > <module 'zope.sqlalchemy' from > '/home/andornaut/.virtualenvs/pyramid/local/lib/python2.7/site-packages/zope/sqlalchemy/__init__.pyc'> > > Whereas, from within Eclipse(PyDev) I am unable to import "zope" or > "zope.sqlalchemy". > > This discrepency in behavior looks to be do to some magic happening in > the.pth file: > > $ cat site-packages/zope.sqlalchemy-0.7-py2.7-nspkg.pth > > import sys,types,os; p = > os.path.join(sys._getframe(1).f_locals['sitedir'], *('zope',)); ie = > os.path.exists(os.path.join(p,'__init__.py')); m = not ie and > sys.modules.setdefault('zope',types.ModuleType('zope')); mp = (m or > []) and m.__dict__.setdefault('__path__',[]); (p not in mp) and > mp.append(p) > > Most of the other Pyramid dependencies are picked up by PyDev, but all > of the ones that do not include an __init__.py file in their root > directory are not picked up ("Repoze" is another example). > > I can work around this by adding __init__.py files to the root > directories of all of the libs that PyDev does not pick up, but this > is obviously not a great solution. (Or perhaps someone can suggest a > more clean workaround in the meantime?) > > Ideally, PyDev would work the same as the command line Python > interpreter - by executing the .pth files and working with whatever > "magic" occurs therein. > > Thanks. ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ pydev-code mailing list pydev-code@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pydev-code