问题
I am trying to use virtualenv with eclipse PyDev. I just execute point my project interpreter to the virtualenv python interpreter.
Everything seems to work fine, but eclipse show me "Unresolved import unittest". When I run the unit test module, it runs well, but the message stills appear in eclipse IDE.
Looking at the virtualenv python lib folder, the unittest module isnt there.
What Am I doing wrong? The python that the virtualenv installed doesnt seen to have all the libraries.
Eclipse interpreter folders. I just add folders of virtualenv.
Image below. Missing unittest and json for eg.
回答1:
It seems there are missing folders from the standard library in your system libs.
Do the following: in your shell, activate the virtual env and then run:
import sys
print('\n'.join(sorted(sys.path)))
Then, add the missing folders to the interpreter (any folder which is not a part of your project should be there).
You can also try to remove and re-add the interpreter as I think the folders were shown to you but were initially unchecked because PyDev thought they were part of your project, not from the interpreter (so, after adding, please go through the list of folders and make sure the proper ones are left checked).
来源:https://stackoverflow.com/questions/41335961/using-virtualenv-with-eclipse