Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1099 PYTHONPATH magically ordered leading to wrong version errors

1.5.1
closed-fixed
nobody
None
8
2011-06-20
2010-03-17
Jörn Hees
No

Hi,
I'm using Pydev 1.5.5.2010030420 from Kubuntu 9.10, but experienced the same problems with earlier versions as well.

I did autoconfig on my python 2.6 and everything worked fine, but during development I found out that there are some newer libraries than in my distribution's package-repositories, so I manually installed them with easy_install into /usr/local/lib/... (SPARQLWrapper, web.py and DBUtils were the packages I installed, but it seems to work with any package.)

Now _without_ re-running autoconfig I don't have the autocompletion and source-browsing from the latest installed versions installed in /usr/local/lib/python2.6/... but from the old versions in /usr/lib/python2.6/..., nevertheless when I _run_ any of my sources _without_ having used autoconfig my path is the following:
['<my src dir>', '/usr/local/lib/python2.6/dist-packages/SPARQLWrapper-1.4.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/web.py-0.33-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/DBUtils-1.0-py2.6.egg', '/home/joern/eclipseworkspaces/Associator/GWAPy/src', '/usr/lib/pymodules/python2.6', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/lib/python2.6', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/plat-linux2', '/usr/local/lib/python2.6/dist-packages']

Notice how the .egg files are the first ones.
So still I wanted autocompletion and source browsing from the new versions, so I removed my configured interpreter and autoconfiged it. After that I still have source browsing from the old package's versions, but also when I run my code it uses the old installed versions. Now when I run the path looks like this:
['<my src dir>', '/usr/lib/pymodules/python2.6', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/lib/python2.6', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/plat-linux2', '/usr/local/lib/python2.6/dist-packages', '/usr/local/lib/python2.6/dist-packages/DBUtils-1.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/SPARQLWrapper-1.4.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/web.py-0.33-py2.6.egg']

Notice how the .egg files are now inserted at the end, which is why I'm now running on old packages, which appear earlier in the path.

When I run python from console without eclipse my sys.path looks like this:
['', '/usr/local/lib/python2.6/dist-packages/SPARQLWrapper-1.4.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/web.py-0.33-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/DBUtils-1.0-py2.6.egg', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/pymodules/python2.6', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-packages']

So on console when executing my code it again runs the most recent version.

Now what I think what happens after autoconfig is that the path is taken from a plain python environment, but then in the GUI the path entries in the Libraries TAB seem to be sorted alphabetically, which breaks the purpose of having a /usr/local, as it always comes after /usr/lib.
I suggest to make it possible to sort the list manually and on autoconfig keep the initial ordering intact.

Regards,
Jörn

Discussion

  • Jörn Hees
    Jörn Hees
    2010-03-17

    Also what I just found out is this dirty workaround: when I manually remove all libraries in the GUI from my PYTHONPATH and then readd them one by one in proper order, everything works fine. (I used the same order as in my standalone python client.)
    Nevertheless I can't insert on top, so whenever I install a newer version of some lib I have to delete all things and readd them one by one. (btw: the hotkey for remove in the libs is the same as for remove from the interpreters, which is why you really have to click a lot)

    Jörn

     
  • Jörn Hees
    Jörn Hees
    2010-03-17

    • priority: 5 --> 7
     
  • Jörn Hees
    Jörn Hees
    2010-03-17

    Also what I just found out is this dirty workaround: when I manually remove all libraries in the GUI from my PYTHONPATH and then readd them one by one in proper order, everything works fine. (I used the same order as in my standalone python client.)
    Nevertheless I can't insert on top, so whenever I install a newer version of some lib I have to delete all things and readd them one by one. (btw: the hotkey for remove in the libs is the same as for remove from the interpreters, which is why you really have to click a lot)

    Jörn

     
  • Jörn Hees
    Jörn Hees
    2010-11-02

    • priority: 7 --> 8
     
  • Jörn Hees
    Jörn Hees
    2010-11-02

    Problem still exists in pydev 1.6.3.
    Also I wonder that you didn't notice the problem in your own http://pydev.org/manual_101_interpreter.html screenshots, where the library paths are obviously sorted alphabetically. This is _wrong_ in most cases.

    I've written a small bash script as a workaround till someone acknowledges this bug,

    It's in the directory where all my different workspaces are subdirs:
    cat adjustPythonPath.sh
    #! /bin/bash

    pypath=$( python <<-EOP
    import sys
    print "|".join(sys.path)
    EOP
    )
    echo $pypath
    find -path './*/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.python.pydev.prefs' |
    while read line ; do
    sed -i.bak -r 's%(^INTERPRETER_PATH_NEW=.+?:/usr/bin/python2.6)(|.+?)(@.+$)%\1'"$pypath"'\3%' "$line"
    done

     
  • Fabio Zadrozny
    Fabio Zadrozny
    2011-06-20

    Can you check if the current nightly build fixes it for you?

    Cheers,

    Fabio

     
  • Fabio Zadrozny
    Fabio Zadrozny
    2011-06-20

    • status: open --> closed-fixed