Using virtualenv with eclipse

邮差的信 提交于 2019-12-10 11:35:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!