25

I am trying to add an interpreter (created using virtualenv) to PyDev but I get the following error:

It seems that the Python /Lib folder (which contains the standard library) was not found /selected during the instal process.

This folder (which contains files such as threading.py and traceback.py) is required for PyDev to function properly (and it must contain the actual source files, not only .pyc files) ...

Note that if this is a virtualenv install, the /Lib folder from the base install needs to be selected (unlike the site-packages which is optional)...

The problem is that there is no /lib folder under my default installation... I created the virtualenv with the 'no-site-packages' option... How can I solve? thanks!

goodolddays
  • 2,595
  • 4
  • 34
  • 51

2 Answers2

23

I've come across this myself before. When adding an interpreter created using virtualenv in PyDev, when it asks for the folders that need to be added to the SYSTEM pythonpath, I had to select
/usr/lib/python2.7
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/plat-linux2
See the screenshot for what I had to do. Here temp is my virtualenv.

enter image description here

Even though the system Python directory was added, PyDev did not pick up the global site packages, so you still achieve the "no-site-packages" effect. I'm assuming you would have to do something similar on Windows i.e. select all the folder in the "Select Needed" dialog, including the C:\Pythonx.x folder.

EDIT: I just tried it out with PyDev 2.3 on Eclipse Indigo (Arch Linux with virtualenv 1.7), and it seems that plat-linux2 does not need to be selected (not sure about lib-tk, but /usr/lib/python2.7 is definitely required). Thanks fijiaaron for pointing it out.

EDIT 2: Pydev 2.5 (and probably 2.6 too, from the docs) still requires the /Lib folder to function properly, though it now lets you ignore the "Python stdlib not found" dialog and add the interpreter anyway (but mentions that it still needs to be included later).

Anshuman Bhaduri
  • 623
  • 7
  • 13
  • 5
    Can this possibly interfere with the virtual env setup if you run things from within that eclipse environment - ie would it end up using the wrong version of interpreter and libs? – Danny Staple Feb 04 '12 at 13:10
  • As long global site-packages directory isn't selected, the virtualenv libs should be used. And the selected directory would only include the interpreter that the virtualenv was created with. Haven't noticed any issues so far. – Anshuman Bhaduri Feb 05 '12 at 02:50
  • 2
    Are you sure /usr/lib/python2.7 has to be selected? [This guy](http://thomasbhatia.blogspot.com/2012/01/flask-virtualenv-and-aptanapydev.html?showComment=1340751023795#c3035572180256963057) doesn't select anything when he sets up the interpreter. – william_grisaitis Jun 26 '12 at 23:01
  • Seems Pydev 2.5 allows you to ignore the dialog but mentions that the /Lib folder needs to be added later for Pydev to function properly. I've updated my answer. Thanks – Anshuman Bhaduri Jun 29 '12 at 12:40
  • @Anshuman, how can you say that the "no-site-packages" effect is still preserved. As **/usr/lib/python2.7** is added to the path, **/usr/lib/python2.7/dist-packages** should be picked up – Deepak Garg Jun 25 '13 at 11:32
  • As I understand, unless `/usr/lib...site-packages` is explicitly added to the `PYTHONPATH`, it will not be searched for modules. You can fire up PyDev's interactive console and check out `sys.path` yourself, just to be sure. – Anshuman Bhaduri Jun 30 '13 at 11:53
0

to skip this message in pydev you can create manual symbolic links to stdlib not linked by virtualenv.

Example:

ln -s /usr/lib/python3.3/threading.py /home/path/to/virtual/myenv/lib/python3.3/threading.py
ln -s /usr/lib/python3.3/traceback.py /home/path/to/virtual/myenv/lib/python3.3/traceback.py

There is a lot of stdlib not linked in virtualenv. Probably you should make as you need manualy.

Look at /usr/lib/python3.3 and compare with /home/path/to/virtual/myenv/lib/python3.3

You can add, per example, /usr/lib/python3.3/concurrent/ in your pydev path.

if you add /usr/lib/python2.7 (or /usr/lib/python3.3) as suggest by Mr. Bhaduri you can explode your virtualenv because your package could look at site-packages directory in /usr/lib/python2.7 and this is exactly what you dont want.

You want isolate your enviroment. You want your package look only in /home/path/to/virtual/myenv/lib/python3.3/site-packages/

macm
  • 1,959
  • 23
  • 25