Base classes missing with Pydev interpreter and virtualenv
Ok, so if I create a brand new virtualenv, then hop into that environment, go into a python shell within that environment, and run 'import logging', for instance, it imports absolutely fine. I can then start up eclipse, create a new interpreter based on the /bin/python in my virtualenv and if I open up a python console within eclipse, based on this new interpreter, I can run 'import logging' again without any problems. I can create a project, with this new interpreter and create a sample file with nothing but
import logging print asdf
I'll get an 'unresolved import' error with the line 'import logging'. This can be resolved by adding in the system lib/pythonX.X directory (in my case /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6) to the interpreter configuration, but I'd be under the impression that this is counter-intuitive for what you'd want to be doing with eclipse and virtualenv.
I know the stuff that's in that lib/pythonX.X directory are pretty much nothing but the base classes, but if they should always be included, should they not just be included anyway? Is this not against the way vi开发者_JS百科rtualenv setting up links to these very classes within it's own lib/pythonX.X directory? Is adding the base python lib/pythonX.X directory to the eclipse interpreter the correct way to do this, or is there problems with doing this?
Am I getting confused by the whole setup, or is it actually confusing and I'm right to ask the question? Thanks for anyone who can help.
I think it's just confusing... You really have to add the paths of the base interpreter when configuring the virtualenv interpreter in PyDev (i.e.: in the command line, when you start that interpreter and do an import sys;print(sys.path)
, the folders of the base interpreter will probably be there, so, they also need to be in PyDev).
精彩评论