FAQ
I'm having an issue with sys.path on Ubuntu. I want some of my home
built packages to overshadow the system packages. Namely, I have built
numpy 1.3.0 from source with atlas support, and I need it to
overshadow the system numpy 1.2.1 which I had to drag along as a
dependency for other stuff. I have numpy 1.3.0 installed into
/usr/local/lib/python2.6/dist-packages/. The issue is that this
directory is added to the path after the
/usr/lib/python2.6/dist-packages/ is added, so python doesnt see my
version of numpy.

I have been combating this with a line in my .bashrc file:

export PYTHONPATH=/usr/local/lib/python2.6/dist-packages

So when I start python from the shell, everything works fine.

Problems show up when python is not executed from the shell, and thus
the path variable is never exported. This can occur when I have
launcher in the gnome panel or i'm executing from within wing-ide.

Is there a way to fix this so that the local dist-packages is added to
sys.path before the system directory ALWAYS? I can do this by editing
site.py but I think it's kind of bad form to do it this way. I feel
there has to be a way to do this without root privileges.

Any ideas?

Cheers,

Chris

Search Discussions

  • Sean DiZazzo at Aug 30, 2009 at 3:51 am

    On Aug 29, 5:39?pm, Chris Colbert wrote:
    I'm having an issue with sys.path on Ubuntu. I want some of my home
    built packages to overshadow the system packages. Namely, I have built
    numpy 1.3.0 from source with atlas support, and I need it to
    overshadow the system numpy 1.2.1 which I had to drag along as a
    dependency for other stuff. I have numpy 1.3.0 installed into
    /usr/local/lib/python2.6/dist-packages/. The issue is that this
    directory is added to the path after the
    /usr/lib/python2.6/dist-packages/ is added, so python doesnt see my
    version of numpy.

    I have been combating this with a line in my .bashrc file:

    export PYTHONPATH=/usr/local/lib/python2.6/dist-packages

    So when I start python from the shell, everything works fine.

    Problems show up when python is not executed from the shell, and thus
    the path variable is never exported. This can occur when I have
    launcher in the gnome panel or i'm executing from within wing-ide.

    Is there a way to fix this so that the local dist-packages is added to
    sys.path before the system directory ALWAYS? I can do this by editing
    site.py but I think it's kind of bad form to do it this way. I feel
    there has to be a way to do this without root privileges.

    Any ideas?

    Cheers,

    Chris
    I think you can modify sys.path inside your application.

    Maybe this will work (at the top of your script):


    import sys
    sys.path[0] = "/usr/local/lib/python2.6/dist-packages"

    import numpy


    PS. Say hi to Steven for me!

    ~Sean
  • Chris Colbert at Aug 30, 2009 at 4:07 pm
    I don't want to have to modify the path in each and every application.

    There has to be a way to do this...

    Personally, I don't agree with the Debian maintainers in the order
    they import anyway; it should be simple for me to overshadow system
    packagers. But that's another story.

    P.S. my first name is Steven!

    Cheers,

    Chris

    On Sat, Aug 29, 2009 at 11:51 PM, Sean DiZazzowrote:
    On Aug 29, 5:39?pm, Chris Colbert wrote:
    I'm having an issue with sys.path on Ubuntu. I want some of my home
    built packages to overshadow the system packages. Namely, I have built
    numpy 1.3.0 from source with atlas support, and I need it to
    overshadow the system numpy 1.2.1 which I had to drag along as a
    dependency for other stuff. I have numpy 1.3.0 installed into
    /usr/local/lib/python2.6/dist-packages/. The issue is that this
    directory is added to the path after the
    /usr/lib/python2.6/dist-packages/ is added, so python doesnt see my
    version of numpy.

    I have been combating this with a line in my .bashrc file:

    export PYTHONPATH=/usr/local/lib/python2.6/dist-packages

    So when I start python from the shell, everything works fine.

    Problems show up when python is not executed from the shell, and thus
    the path variable is never exported. This can occur when I have
    launcher in the gnome panel or i'm executing from within wing-ide.

    Is there a way to fix this so that the local dist-packages is added to
    sys.path before the system directory ALWAYS? I can do this by editing
    site.py but I think it's kind of bad form to do it this way. I feel
    there has to be a way to do this without root privileges.

    Any ideas?

    Cheers,

    Chris
    I think you can modify sys.path inside your application.

    Maybe this will work (at the top of your script):


    import sys
    sys.path[0] = "/usr/local/lib/python2.6/dist-packages"

    import numpy


    PS. ?Say hi to Steven for me!

    ~Sean
    --
    http://mail.python.org/mailman/listinfo/python-list
  • Christian Heimes at Aug 30, 2009 at 4:29 pm

    Chris Colbert wrote:
    Is there a way to fix this so that the local dist-packages is added to
    sys.path before the system directory ALWAYS? I can do this by editing
    site.py but I think it's kind of bad form to do it this way. I feel
    there has to be a way to do this without root privileges.

    Any ideas?
    Have you read my blog entry about my PEP 370?
    http://lipyrary.blogspot.com/2009/08/how-to-add-new-module-search-path.html

    Christian
  • Chris Colbert at Aug 30, 2009 at 5:03 pm
    Great! That was the solution I was looking for. Thanks!

    Chris

    On Sun, Aug 30, 2009 at 12:29 PM, Christian Heimeswrote:
    Chris Colbert wrote:
    Is there a way to fix this so that the local dist-packages is added to
    sys.path before the system directory ALWAYS? I can do this by editing
    site.py but I think it's kind of bad form to do it this way. I feel
    there has to be a way to do this without root privileges.

    Any ideas?
    Have you read my blog entry about my PEP 370?
    http://lipyrary.blogspot.com/2009/08/how-to-add-new-module-search-path.html

    Christian

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedAug 30, '09 at 12:39a
activeAug 30, '09 at 5:03p
posts5
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase